attachment

package
v0.0.0-...-5ccfce3 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package attachment exposes the CLI-shaped facade for managing entity file attachments (attach, list). The service depends only on the focused primitives it needs (Store, Meta, EntityManager) so it can be constructed at any wiring site.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Store         store.Store
	Meta          *metamodel.Metamodel
	EntityManager entitymanager.EntityManager
}

Deps is the dependency bundle New requires. Every field is mandatory; New returns an error if any is nil.

type Info

type Info struct {
	Property    string
	Path        string
	FileName    string
	ContentType string
	Size        int64
}

Info describes a single file attachment on an entity.

type Result

type Result struct {
	Path     string
	FileName string
}

Result is the outcome of Service.Attach.

type Service

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

Service implements the attachment-facade methods that CLI invokes. Constructed once at the wiring site and shared across subcommands.

func New

func New(d Deps) (*Service, error)

New constructs a Service. Returns an error if any required dependency is nil — CLAUDE.md "constructors reject nil required fields."

func (*Service) Attach

func (s *Service) Attach(ctx context.Context, entityID, filePath, property string) (*Result, error)

Attach streams the file at filePath into the store at `attachments/<entityID>/<property>/<base(filePath)>` and records the path on the entity's property. The stored file overwrites any existing attachment at the same path — file-type properties hold at most one attachment.

If property is empty, the first file-type property declared on the entity type (in alphabetical order — see [findFileProperty]) is used.

func (*Service) List

func (s *Service) List(ctx context.Context, entityID string) ([]Info, error)

List returns all attachments for an entity. Content type is inferred from the filename extension on the fly; there is no persisted metadata sidecar.

Jump to

Keyboard shortcuts

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