Documentation
¶
Index ¶
- func CreateComponent(cmp *models.Component) error
- func CreateSingleItem(st *models.Singleton, itemData map[string]any) (*models.SingleItem, error)
- func CreateUser(user *models.User) error
- func DeleteAgent(agentID uint) error
- func DeleteCollection(collectionID uint) error
- func DeleteComponent(name string) error
- func DeleteItem(id uint) error
- func DeleteRole(id uint) error
- func DeleteSingleItem(SingletonName string) error
- func DeleteSingleton(SingletonID uint) error
- func DeleteUser(id uint) error
- func FetchNestedRelations(collection models.Collection, data models.JSONMap, level uint) (models.JSONMap, error)
- func FindAgentsByEventTrigger(collectionName string, eventType string) ([]models.Agent, error)
- func GetAgentByID(id uint) (*models.Agent, error)
- func GetAgentByName(name string) (*models.Agent, error)
- func GetAllAgents(filters map[string]any, rangeValues []int) ([]models.Agent, int, error)
- func GetAllCollections(filters map[string]any, sortValues []string, rangeValues []int) ([]models.Collection, int, error)
- func GetAllRoles() ([]models.UserRole, error)
- func GetAllUsers() ([]models.User, error)
- func GetCollectionByID(id uint) (*models.Collection, error)
- func GetCollectionByName(name string) (*models.Collection, error)
- func GetCollectionSchema(id int) (map[string]any, error)
- func GetComponentByName(name string) (*models.Component, error)
- func GetConversationHistory(agentID uint) ([]llm.Message, error)
- func GetItemByID(collectionID uint, itemID uint) (*models.Item, error)
- func GetItems(collectionID uint, page, pageSize int) ([]models.Item, int, error)
- func GetRoleByID(id uint) (*models.UserRole, error)
- func GetRoleByName(name string) (*models.UserRole, error)
- func GetSingleItemByType(SingletonName string) (*models.SingleItem, error)
- func GetSingletonByName(name string) (*models.Singleton, error)
- func GetUserByID(id uint) (*models.User, error)
- func GetUserByUsername(username string) (*models.User, error)
- func InitAsynqClient(client *asynq.Client)
- func IsReferencedByOtherCollections(collectionName string, tx *gorm.DB) ([]models.Attribute, error)
- func SaveAgent(agent *models.Agent) error
- func SaveCollection(ct *models.Collection) error
- func SaveConversationHistory(agentID uint, messages []llm.Message) error
- func SaveIteem(collection models.Collection, itemData models.JSONMap) (*models.Item, error)
- func SaveItem(collection models.Collection, itemData models.JSONMap) (*models.Item, error)
- func SaveItemWithTransaction(tx *gorm.DB, item *models.Item) error
- func SaveOrUpdateSingleton(st *models.Singleton) error
- func SaveRole(role *models.UserRole) error
- func UpdateAgent(id uint, updated *models.Agent) error
- func UpdateCollection(id uint, updated *models.Collection) error
- func UpdateComponent(name string, updated *models.Component) error
- func UpdateItem(itemID uint, data models.JSONMap) error
- func UpdateRole(id uint, updates map[string]interface{}) error
- func UpdateSingleItem(SingletonName string, newData map[string]any) (*models.SingleItem, error)
- func UpdateUser(id uint, updates map[string]interface{}) error
- type DBToolCall
- type DuplicateEntryError
- type GeneralDatabaseError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateComponent ¶
CreateComponent stores a new Component definition in the DB, including its attributes.
func CreateSingleItem ¶
CreateSingleItem creates a new SingleItem for a given Singleton. Returns an error if an item already exists for that Singleton (one-to-one).
func CreateUser ¶
func DeleteAgent ¶
DeleteAgent deletes an agent from the database by its ID.
func DeleteCollection ¶
DeleteCollection deletes a collection and all associated data by its ID.
func DeleteComponent ¶
DeleteComponent removes a component definition by name. GORM's cascading delete will handle the attributes.
func DeleteItem ¶
func DeleteSingleItem ¶
DeleteSingleItem removes the SingleItem for a given single type name (if it exists).
func DeleteSingleton ¶
DeleteSingleton permanently deletes a single type by its ID (including attributes). Note: Strapi typically doesn't expose DELETE for single types, but you can implement it if needed.
func FetchNestedRelations ¶
func FindAgentsByEventTrigger ¶
FindAgentsByEventTrigger queries for agents subscribed to a specific collection event. TOFIX This version uses a query for JSONB that is compatible with PostgreSQL.
func GetAgentByID ¶
GetAgentByID retrieves an agent by its ID.
func GetAgentByName ¶
GetAgentByName retrieves an agent by its name.
func GetAllAgents ¶
GetAllAgents retrieves agents with optional filtering and pagination.
func GetAllCollections ¶
func GetAllCollections(filters map[string]any, sortValues []string, rangeValues []int) ([]models.Collection, int, error)
GetAllCollectionsWithFilters retrieves collections with optional filtering, sorting, and pagination.
func GetAllRoles ¶
GetAllRoles retrieves all roles from the database.
func GetAllUsers ¶
GetAllUsers retrieves all users from the database.
func GetCollectionByID ¶
func GetCollectionByID(id uint) (*models.Collection, error)
GetCollectionByID retrieves a collection by its ID.
func GetCollectionByName ¶
func GetCollectionByName(name string) (*models.Collection, error)
GetCollectionByName retrieves a collection by its name.
func GetCollectionSchema ¶
GetCollectionSchema retrieves the schema definition of a collection by name.
func GetComponentByName ¶
GetComponentByName retrieves a component definition by its name.
func GetConversationHistory ¶
GetConversationHistory retrieves the messages for an agent.
func GetItemByID ¶
GetItemByID fetches an item by its ID and collection ID.
func GetRoleByID ¶
GetRoleByID retrieves a role by its ID.
func GetRoleByName ¶
GetRoleByName retrieves a role by its name.
func GetSingleItemByType ¶
func GetSingleItemByType(SingletonName string) (*models.SingleItem, error)
GetSingleItemByType retrieves the SingleItem for a given single type name.
func GetSingletonByName ¶
GetSingletonByName retrieves a single type by its name (including associated attributes).
func GetUserByID ¶
GetUserByID retrieves a user by their ID.
func GetUserByUsername ¶
GetUserByUsername retrieves a user by their username.
func InitAsynqClient ¶
func SaveAgent ¶
SaveAgent persists an Agent to the database, handling both new and soft-deleted records.
func SaveCollection ¶
func SaveCollection(ct *models.Collection) error
SaveCollection persists a Collection to the database, handling both new and soft-deleted records.
func SaveConversationHistory ¶
SaveConversationHistory replaces the old history with the new one for an agent.
func SaveItem ¶
SaveItem creates a new item in the database and then publishes a generic 'item:created' event to the dispatcher queue.
func SaveItemWithTransaction ¶
SaveItem creates a new item in the database and then publishes a generic 'item:created' event to the dispatcher queue.
func SaveOrUpdateSingleton ¶
SaveOrUpdateSingleton either creates a new single type or updates/restores a previously soft-deleted record with the same name.
This mimics the "single type" behavior in Strapi (one record per name).
func UpdateAgent ¶
UpdateAgent updates an existing Agent in the database by its ID.
func UpdateCollection ¶
func UpdateCollection(id uint, updated *models.Collection) error
UpdateCollectionByID updates an existing Collection in the database by its ID.
func UpdateComponent ¶
UpdateComponent updates an existing component definition by name.
func UpdateRole ¶
UpdateRole updates an existing role by ID.
func UpdateSingleItem ¶
UpdateSingleItem updates the SingleItem for a given single type with new data. Returns the updated SingleItem or an error if not found or validation fails.
func UpdateUser ¶
UpdateUser updates the details of an existing user by ID.
Types ¶
type DBToolCall ¶
type DBToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
FunctionName string `json:"function_name"`
Arguments string `json:"arguments"`
}
DBToolCall represents a simplified tool call for database storage
type DuplicateEntryError ¶
type DuplicateEntryError struct {
Field string
}
Custom error types
func (*DuplicateEntryError) Error ¶
func (e *DuplicateEntryError) Error() string
type GeneralDatabaseError ¶
type GeneralDatabaseError struct {
Message string
}
func (*GeneralDatabaseError) Error ¶
func (e *GeneralDatabaseError) Error() string