store

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MPL-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package store implements the prompt template storage and management logic. It provides CRUD operations for prompt bundles and templates, supports soft deletion, and background cleanup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitPromptTemplateStoreHandlers

func InitPromptTemplateStoreHandlers(api huma.API, store *PromptTemplateStore)

InitPromptTemplateStoreHandlers registers all endpoints for prompt bundles and templates.

Types

type BuiltInData

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

BuiltInData keeps the built-in prompt assets and an overlay with enable flags.

func NewBuiltInData

func NewBuiltInData(
	ctx context.Context,
	overlayBaseDir string,
	builtInSnapshotMaxAge time.Duration,
	opts ...BuiltInDataOption,
) (data *BuiltInData, err error)

func (*BuiltInData) Close added in v0.0.79

func (d *BuiltInData) Close() error

func (*BuiltInData) GetBuiltInBundle

func (d *BuiltInData) GetBuiltInBundle(
	ctx context.Context,
	id bundleitemutils.BundleID,
) (spec.PromptBundle, error)

func (*BuiltInData) GetBuiltInTemplate

func (*BuiltInData) ListBuiltInData

ListBuiltInData returns a deep copy of the cached snapshot.

func (*BuiltInData) SetBundleEnabled

func (d *BuiltInData) SetBundleEnabled(
	ctx context.Context,
	id bundleitemutils.BundleID,
	enabled bool,
) (bundle spec.PromptBundle, err error)

SetBundleEnabled toggles a bundle flag.

func (*BuiltInData) SetTemplateEnabled

func (d *BuiltInData) SetTemplateEnabled(
	ctx context.Context,
	bundleID bundleitemutils.BundleID,
	slug bundleitemutils.ItemSlug,
	version bundleitemutils.ItemVersion,
	enabled bool,
) (template spec.PromptTemplate, err error)

SetTemplateEnabled toggles a template flag.

type BuiltInDataOption

type BuiltInDataOption func(*BuiltInData)

func WithBundlesFS

func WithBundlesFS(fsys fs.FS, rootDir string) BuiltInDataOption

WithBundlesFS overrides the default embedded FS.

type Option

type Option func(*PromptTemplateStore) error

Option is a functional option for PromptTemplateStore.

type PromptTemplateStore

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

PromptTemplateStore is the main store for prompt bundles and templates. It manages bundle and template CRUD, soft deletion, background cleanup.

func NewPromptTemplateStore

func NewPromptTemplateStore(baseDir string, opts ...Option) (*PromptTemplateStore, error)

func (*PromptTemplateStore) Close

func (s *PromptTemplateStore) Close() error

Close gracefully terminates the background cleanup goroutine.

func (*PromptTemplateStore) DeletePromptBundle

DeletePromptBundle soft-deletes a bundle if it is empty.

func (*PromptTemplateStore) DeletePromptTemplate

DeletePromptTemplate hard-deletes a template version.

func (*PromptTemplateStore) GetPromptTemplate

GetPromptTemplate returns the exact requested template version.

func (*PromptTemplateStore) ListPromptBundles

ListPromptBundles lists prompt bundles with optional filtering and pagination. If PageToken is provided its embedded parameters override the request body.

func (*PromptTemplateStore) ListPromptTemplates

ListPromptTemplates streams every stored version. Server-side filters are bundle-IDs, tags and include disabled.

func (*PromptTemplateStore) PatchPromptBundle

PatchPromptBundle toggles the enabled flag of a bundle.

func (*PromptTemplateStore) PatchPromptTemplate

PatchPromptTemplate enables or disables a template version.

func (*PromptTemplateStore) PutPromptBundle

PutPromptBundle creates or replaces a prompt bundle.

func (*PromptTemplateStore) PutPromptTemplate

PutPromptTemplate creates a new prompt template version. Returns an error if the (slug, version) already exists.

Jump to

Keyboard shortcuts

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