collection

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	RootID       basespec.RootID         `json:"rootID"`
	CollectionID basespec.CollectionID   `json:"collectionID"`
	SourceID     basespec.SourceID       `json:"sourceID"`
	Role         basespec.AttachmentRole `json:"role"`
	Enabled      bool                    `json:"enabled"`
	Data         json.RawMessage         `json:"-"`
	Revision     uint64                  `json:"revision"`
	CreatedAt    time.Time               `json:"createdAt"`
	ModifiedAt   time.Time               `json:"modifiedAt"`
}

func (Attachment) Clone

func (a Attachment) Clone() Attachment

func (Attachment) Validate

func (a Attachment) Validate() error

type AttachmentDraft

type AttachmentDraft struct {
	SourceID basespec.SourceID       `json:"sourceID"`
	Role     basespec.AttachmentRole `json:"role"`
	Enabled  bool                    `json:"enabled"`
	Data     json.RawMessage         `json:"data"`
}

type AttachmentReplacement

type AttachmentReplacement struct {
	ExpectedCollectionRevision uint64            `json:"expectedCollectionRevision"`
	PreviousSourceID           basespec.SourceID `json:"previousSourceID,omitempty"`
	PreviousAttachmentRevision uint64            `json:"previousAttachmentRevision,omitempty"`
	Replacement                AttachmentDraft   `json:"replacement"`
}

type AttachmentUpdate

type AttachmentUpdate struct {
	ExpectedCollectionRevision uint64                  `json:"expectedCollectionRevision"`
	ExpectedAttachmentRevision uint64                  `json:"expectedAttachmentRevision"`
	Role                       basespec.AttachmentRole `json:"role"`
	Enabled                    bool                    `json:"enabled"`
	Data                       json.RawMessage         `json:"data"`
}

type Collection

type Collection struct {
	ID          basespec.CollectionID   `json:"id"`
	RootID      basespec.RootID         `json:"rootID"`
	Kind        basespec.CollectionKind `json:"kind"`
	DisplayName string                  `json:"displayName"`
	Description string                  `json:"description,omitempty"`
	Enabled     bool                    `json:"enabled"`
	Data        json.RawMessage         `json:"-"`
	Revision    uint64                  `json:"revision"`
	CreatedAt   time.Time               `json:"createdAt"`
	ModifiedAt  time.Time               `json:"modifiedAt"`
	RetiredAt   *time.Time              `json:"retiredAt,omitempty"`
}

func (Collection) Clone

func (c Collection) Clone() Collection

func (Collection) Ref

func (c Collection) Ref() CollectionRef

func (Collection) Validate

func (c Collection) Validate() error

type CollectionRef

type CollectionRef struct {
	RootID       basespec.RootID       `json:"rootID"`
	CollectionID basespec.CollectionID `json:"collectionID"`
}

func (CollectionRef) Validate

func (r CollectionRef) Validate() error

type Draft

type Draft struct {
	Kind        basespec.CollectionKind `json:"kind"`
	DisplayName string                  `json:"displayName"`
	Description string                  `json:"description,omitempty"`
	Enabled     bool                    `json:"enabled"`
	Data        json.RawMessage         `json:"data"`
}

type Reader

type Reader interface {
	Get(
		ctx context.Context,
		ref CollectionRef,
	) (Collection, error)

	ListByRoot(
		ctx context.Context,
		rootID basespec.RootID,
	) ([]Collection, error)

	GetAttachment(
		ctx context.Context,
		ref CollectionRef,
		sourceID basespec.SourceID,
	) (Attachment, error)

	ListAttachments(
		ctx context.Context,
		ref CollectionRef,
	) ([]Attachment, error)
}

type Repository

type Repository interface {
	Reader
	RetiredReader

	Create(
		ctx context.Context,
		value Collection,
		attachments []Attachment,
	) error

	Update(
		ctx context.Context,
		value Collection,
		expectedRevision uint64,
	) error

	Retire(
		ctx context.Context,
		value Collection,
		expectedRevision uint64,
	) error

	Purge(
		ctx context.Context,
		ref CollectionRef,
		expectedRevision uint64,
	) error

	Attach(
		ctx context.Context,
		value Attachment,
		expectedCollectionRevision uint64,
	) (Collection, error)

	UpdateAttachment(
		ctx context.Context,
		value Attachment,
		expectedCollectionRevision uint64,
		expectedAttachmentRevision uint64,
	) (Collection, error)

	Detach(
		ctx context.Context,
		ref CollectionRef,
		sourceID basespec.SourceID,
		expectedCollectionRevision uint64,
		expectedAttachmentRevision uint64,
		modifiedAt time.Time,
	) (Collection, error)

	ReplaceAttachment(
		ctx context.Context,
		ref CollectionRef,
		previousSourceID basespec.SourceID,
		expectedPreviousRevision uint64,
		replacement Attachment,
		expectedCollectionRevision uint64,
	) (Collection, error)
}

type RetiredReader

type RetiredReader interface {
	GetRetired(
		ctx context.Context,
		ref CollectionRef,
	) (Collection, error)
}

RetiredReader is intentionally separate from Reader. Ordinary consumers must not treat retired Collections as active aggregates, while typed domain lifecycle services need to verify Collection kind before destructive purge.

type Service

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

func NewService

func NewService(
	repository Repository,
	sources sourceReader,
	ids uuidutil.Generator,
	timeClock clockutil.Clock,
) (*Service, error)

func (*Service) Attach

func (s *Service) Attach(
	ctx context.Context,
	ref CollectionRef,
	expectedCollectionRevision uint64,
	draft AttachmentDraft,
) (Collection, Attachment, error)

func (*Service) Create

func (s *Service) Create(
	ctx context.Context,
	rootID basespec.RootID,
	draft Draft,
	attachmentDrafts []AttachmentDraft,
) (Collection, []Attachment, error)

func (*Service) Detach

func (s *Service) Detach(
	ctx context.Context,
	ref CollectionRef,
	sourceID basespec.SourceID,
	expectedCollectionRevision uint64,
	expectedAttachmentRevision uint64,
) (Collection, error)

func (*Service) Get

func (s *Service) Get(
	ctx context.Context,
	ref CollectionRef,
) (Collection, error)

func (*Service) GetAttachment

func (s *Service) GetAttachment(
	ctx context.Context,
	ref CollectionRef,
	sourceID basespec.SourceID,
) (Attachment, error)

func (*Service) GetRetired

func (s *Service) GetRetired(
	ctx context.Context,
	ref CollectionRef,
) (Collection, error)

GetRetired is a privileged lifecycle read. It is intentionally not exposed by public consumer APIs because a retired Collection cannot be used as an active aggregate.

func (*Service) ListAttachments

func (s *Service) ListAttachments(
	ctx context.Context,
	ref CollectionRef,
) ([]Attachment, error)

func (*Service) ListByRoot

func (s *Service) ListByRoot(
	ctx context.Context,
	rootID basespec.RootID,
) ([]Collection, error)

func (*Service) Purge

func (s *Service) Purge(
	ctx context.Context,
	ref CollectionRef,
	expectedRevision uint64,
) error

func (*Service) ReplaceAttachment

func (s *Service) ReplaceAttachment(
	ctx context.Context,
	ref CollectionRef,
	replacement AttachmentReplacement,
) (Collection, Attachment, error)

func (*Service) Retire

func (s *Service) Retire(
	ctx context.Context,
	ref CollectionRef,
	expectedRevision uint64,
) (Collection, error)

func (*Service) Update

func (s *Service) Update(
	ctx context.Context,
	ref CollectionRef,
	update Update,
) (Collection, error)

func (*Service) UpdateAttachment

func (s *Service) UpdateAttachment(
	ctx context.Context,
	ref CollectionRef,
	sourceID basespec.SourceID,
	update AttachmentUpdate,
) (Collection, Attachment, error)

type Update

type Update struct {
	ExpectedRevision uint64          `json:"expectedRevision"`
	DisplayName      string          `json:"displayName"`
	Description      string          `json:"description,omitempty"`
	Enabled          bool            `json:"enabled"`
	Data             json.RawMessage `json:"data"`
}

Jump to

Keyboard shortcuts

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