Documentation
¶
Overview ¶
Package base provides common repository helpers over workspace stores.
It implements generic list/load/save/delete behavior reused by typed repos.
Index ¶
- type Repository
- func (r *Repository[T]) Add(ctx context.Context, name string, data []byte) error
- func (r *Repository[T]) Delete(ctx context.Context, name string) error
- func (r *Repository[T]) Filename(name string) string
- func (r *Repository[T]) GetRaw(ctx context.Context, name string) ([]byte, error)
- func (r *Repository[T]) List(ctx context.Context) ([]string, error)
- func (r *Repository[T]) Load(ctx context.Context, name string) (*T, error)
- func (r *Repository[T]) ResolveFilename(ctx context.Context, name string) (string, error)
- func (r *Repository[T]) Save(ctx context.Context, name string, obj *T) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository[T any] struct { // contains filtered or unexported fields }
Repository generic CRUD for YAML/JSON resources stored under $AGENTLY_WORKSPACE/<kind>/.
func New ¶
func New[T any](fs afs.Service, kind string) *Repository[T]
New constructs a repository for a specific workspace kind (e.g. "models").
func NewWithStore ¶
func NewWithStore[T any](store workspace.Store, kind string) *Repository[T]
NewWithStore constructs a repository backed by a workspace.Store.
func (*Repository[T]) Delete ¶
func (r *Repository[T]) Delete(ctx context.Context, name string) error
Delete removes file.
func (*Repository[T]) Filename ¶
func (r *Repository[T]) Filename(name string) string
Filename is a compatibility helper for legacy callers that do not pass context. New code should prefer ResolveFilename so lookup respects cancellation.
func (*Repository[T]) List ¶
func (r *Repository[T]) List(ctx context.Context) ([]string, error)
List basenames (without extension).
func (*Repository[T]) Load ¶
func (r *Repository[T]) Load(ctx context.Context, name string) (*T, error)
Load unmarshals YAML/JSON into *T.
func (*Repository[T]) ResolveFilename ¶
ResolveFilename resolves a resource path using the caller context.