d2

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: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewD2OracleRepository

func NewD2OracleRepository() repository.OracleRepository

NewD2OracleRepository creates a new D2 repository with Oracle support.

func NewD2OracleRepositoryWithSecurity

func NewD2OracleRepositoryWithSecurity(config SecurityConfig) (repository.OracleRepository, error)

NewD2OracleRepositoryWithSecurity creates an Oracle repository with explicit security dependencies.

func NewD2Repository

func NewD2Repository() repository.DiagramRepository

NewD2Repository creates a D2 repository secured to the current working directory.

func NewD2RepositoryWithSecurity

func NewD2RepositoryWithSecurity(config SecurityConfig) (repository.DiagramRepository, error)

NewD2RepositoryWithSecurity creates a D2 repository with explicit security dependencies.

Types

type D2OracleRepository

type D2OracleRepository struct {
	*D2Repository
	// contains filtered or unexported fields
}

D2OracleRepository extends D2Repository with Oracle capabilities

func (*D2OracleRepository) CreateElement

func (r *D2OracleRepository) CreateElement(ctx context.Context, diagramID string, boardPath []string, key string) (*entity.OracleResult, error)

CreateElement creates a new shape or connection

func (*D2OracleRepository) DeleteElement

func (r *D2OracleRepository) DeleteElement(ctx context.Context, diagramID string, boardPath []string, key string) (*entity.OracleResult, error)

DeleteElement deletes a shape or connection

func (*D2OracleRepository) GetChildren

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

GetChildren retrieves child element IDs

func (*D2OracleRepository) GetContent

func (r *D2OracleRepository) GetContent(ctx context.Context, diagramID string) (string, error)

GetContent returns the current source, including Oracle edits.

func (*D2OracleRepository) GetEdge

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

GetEdge retrieves edge information

func (*D2OracleRepository) GetObject

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

GetObject retrieves object information

func (*D2OracleRepository) LoadDiagram

func (r *D2OracleRepository) LoadDiagram(ctx context.Context, diagramID string, content string) error

LoadDiagram loads a diagram from D2 text.

func (*D2OracleRepository) MoveElement

func (r *D2OracleRepository) MoveElement(ctx context.Context, diagramID string, boardPath []string, key, newKey string, includeDescendants bool) (*entity.OracleResult, error)

MoveElement moves a shape to a new container

func (*D2OracleRepository) RenameElement

func (r *D2OracleRepository) RenameElement(ctx context.Context, diagramID string, boardPath []string, key, newName string) (*entity.OracleResult, error)

RenameElement renames a shape or connection

func (*D2OracleRepository) ReplaceContent

func (r *D2OracleRepository) ReplaceContent(ctx context.Context, diagramID, content string) error

ReplaceContent validates content before atomically replacing stored source.

func (*D2OracleRepository) SerializeDiagram

func (r *D2OracleRepository) SerializeDiagram(ctx context.Context, diagramID string) (string, error)

SerializeDiagram converts the current graph state back to D2 text

func (*D2OracleRepository) SetAttribute

func (r *D2OracleRepository) SetAttribute(ctx context.Context, diagramID string, boardPath []string, key string, tag, value *string) (*entity.OracleResult, error)

SetAttribute sets attributes on a shape or connection

type D2Repository

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

D2Repository implements the DiagramRepository interface using D2.

func (*D2Repository) Create

func (r *D2Repository) Create(ctx context.Context, diagram *entity.Diagram) error

Create creates a new diagram programmatically.

func (*D2Repository) Export

func (r *D2Repository) Export(ctx context.Context, diagramID string, format entity.ExportFormat) (io.Reader, error)

Export exports the diagram to the specified format.

func (*D2Repository) ExportWithOptions

func (r *D2Repository) ExportWithOptions(ctx context.Context, diagramID string, format entity.ExportFormat, options entity.RenderOptions) (io.Reader, error)

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

func (*D2Repository) FormatContent

func (r *D2Repository) FormatContent(ctx context.Context, content string) (string, error)

FormatContent formats valid D2 source without storing it.

func (*D2Repository) GetContent

func (r *D2Repository) GetContent(ctx context.Context, diagramID string) (string, error)

GetContent returns the stored D2 source.

func (*D2Repository) Render

func (r *D2Repository) Render(ctx context.Context, content string, format entity.ExportFormat, theme *entity.Theme) (io.Reader, error)

Render renders D2 text with backward-compatible theme handling.

func (*D2Repository) RenderWithOptions

func (r *D2Repository) RenderWithOptions(ctx context.Context, content string, format entity.ExportFormat, options entity.RenderOptions) (io.Reader, error)

RenderWithOptions renders content entirely through public D2 v0.9 Go APIs.

func (*D2Repository) ReplaceContent

func (r *D2Repository) ReplaceContent(ctx context.Context, diagramID, content string) error

ReplaceContent validates content before atomically replacing stored source.

func (*D2Repository) Validate

func (r *D2Repository) Validate(ctx context.Context, content string) (*entity.DiagramValidationResult, error)

Validate validates D2 source and normalizes compiler diagnostics.

type OracleSession

type OracleSession struct {
	DiagramID    string
	Graph        *d2graph.Graph
	AST          *d2ast.Map
	LastModified time.Time
	Operations   []entity.OracleOperation // History tracking
}

OracleSession represents an active Oracle editing session

type SecurityConfig

type SecurityConfig struct {
	Workspaces    *workspace.Roots
	HTTPClient    *http.Client
	MaxAssetBytes int64
}

SecurityConfig supplies the confined workspaces and remote client used during compilation and rendering.

Jump to

Keyboard shortcuts

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