Documentation
¶
Overview ¶
ABOUTME: Database connection management and initialization ABOUTME: Handles opening SQLite database with WAL mode at XDG path
ABOUTME: Database operations for follow-up tracking ABOUTME: Handles contact cadence, interaction logging, and follow-up queries
ABOUTME: Database schema definitions and migrations ABOUTME: Handles SQLite table creation and initialization
ABOUTME: Database operations for sync_state and sync_log tables ABOUTME: Manages sync status, tokens, and import tracking for external services
ABOUTME: Database operations for task management ABOUTME: Provides CRUD operations and queries for TaskObject
Index ¶
- Constants
- Variables
- func AddDealNote(db *sql.DB, note *models.DealNote) error
- func CheckSyncLogExists(db *sql.DB, sourceService, sourceID string) (bool, error)
- func CreateCompany(db *sql.DB, company *models.Company) error
- func CreateContact(db *sql.DB, contact *models.Contact) error
- func CreateContactCadence(db *sql.DB, cadence *models.ContactCadence) error
- func CreateDeal(db *sql.DB, deal *models.Deal) error
- func CreateRelationship(db *sql.DB, relationship *models.Relationship) error
- func CreateSyncLog(db *sql.DB, id, sourceService, sourceID, entityType, entityID, metadata string) error
- func CreateTask(db *sql.DB, task *objects.TaskObject) error
- func DeleteCompany(db *sql.DB, id uuid.UUID) error
- func DeleteContact(db *sql.DB, id uuid.UUID) error
- func DeleteDeal(db *sql.DB, id uuid.UUID) error
- func DeleteRelationship(db *sql.DB, id uuid.UUID) error
- func DeleteTask(db *sql.DB, id uuid.UUID) error
- func FindCompanies(db *sql.DB, query string, limit int) ([]models.Company, error)
- func FindCompanyByName(db *sql.DB, name string) (*models.Company, error)
- func FindContactRelationships(db *sql.DB, contactID uuid.UUID, relationshipType string) ([]models.Relationship, error)
- func FindContacts(db *sql.DB, query string, companyID *uuid.UUID, limit int) ([]models.Contact, error)
- func FindDeals(db *sql.DB, stage string, companyID *uuid.UUID, limit int) ([]models.Deal, error)
- func FindRelationshipsBetween(db *sql.DB, contactID1, contactID2 uuid.UUID) ([]models.Relationship, error)
- func GetAllRelationships(db *sql.DB) ([]models.Relationship, error)
- func GetCompany(db *sql.DB, id uuid.UUID) (*models.Company, error)
- func GetContact(db *sql.DB, id uuid.UUID) (*models.Contact, error)
- func GetContactCadence(db *sql.DB, contactID uuid.UUID) (*models.ContactCadence, error)
- func GetContactRelationships(db *sql.DB, contactID uuid.UUID) ([]models.Relationship, error)
- func GetDeal(db *sql.DB, id uuid.UUID) (*models.Deal, error)
- func GetDealNotes(db *sql.DB, dealID uuid.UUID) ([]models.DealNote, error)
- func GetFollowupList(db *sql.DB, limit int) ([]models.FollowupContact, error)
- func GetInteractionHistory(db *sql.DB, contactID uuid.UUID, limit int) ([]models.InteractionLog, error)
- func GetRecentInteractions(db *sql.DB, days int, limit int) ([]models.InteractionLog, error)
- func GetRelationship(db *sql.DB, id uuid.UUID) (*models.Relationship, error)
- func GetRelationshipsBetween(db *sql.DB, contactID1, contactID2 uuid.UUID) ([]models.Relationship, error)
- func GetTask(db *sql.DB, id uuid.UUID) (*objects.TaskObject, error)
- func InitSchema(db *sql.DB) error
- func ListDueSoonTasks(db *sql.DB, days int) ([]*objects.TaskObject, error)
- func ListOverdueTasks(db *sql.DB) ([]*objects.TaskObject, error)
- func ListTasks(db *sql.DB, filter *TaskFilter) ([]*objects.TaskObject, error)
- func ListTasksByRelatedRecord(db *sql.DB, recordID uuid.UUID) ([]*objects.TaskObject, error)
- func LogInteraction(db *sql.DB, interaction *models.InteractionLog) error
- func ObjectToCompany(obj *Object) (*models.Company, error)
- func ObjectToContact(obj *Object) (*models.Contact, error)
- func ObjectToDeal(obj *Object) (*models.Deal, error)
- func OpenDatabase(path string) (*sql.DB, error)
- func SetContactCadence(db *sql.DB, contactID uuid.UUID, days int, strength string) error
- func UpdateCadenceAfterInteraction(db *sql.DB, contactID uuid.UUID, timestamp time.Time) error
- func UpdateCompany(db *sql.DB, id uuid.UUID, updates *models.Company) error
- func UpdateContact(db *sql.DB, id uuid.UUID, updates *models.Contact) error
- func UpdateContactLastContacted(db *sql.DB, contactID uuid.UUID, timestamp time.Time) error
- func UpdateDeal(db *sql.DB, deal *models.Deal) error
- func UpdateRelationship(db *sql.DB, id uuid.UUID, relType, ctx string) error
- func UpdateSyncStatus(db *sql.DB, service, status string, errorMsg *string) error
- func UpdateSyncToken(db *sql.DB, service, token string) error
- func UpdateTask(db *sql.DB, task *objects.TaskObject) error
- type Object
- type ObjectsRepository
- func (r *ObjectsRepository) Create(ctx context.Context, obj *Object) error
- func (r *ObjectsRepository) Delete(ctx context.Context, id string) error
- func (r *ObjectsRepository) Get(ctx context.Context, id string) (*Object, error)
- func (r *ObjectsRepository) List(ctx context.Context, objectKind string) ([]*Object, error)
- func (r *ObjectsRepository) Update(ctx context.Context, obj *Object) error
- type Relationship
- type RelationshipsRepository
- func (r *RelationshipsRepository) Create(ctx context.Context, rel *Relationship) error
- func (r *RelationshipsRepository) Delete(ctx context.Context, id string) error
- func (r *RelationshipsRepository) FindBetween(ctx context.Context, objectID1, objectID2 string) ([]*Relationship, error)
- func (r *RelationshipsRepository) FindBySource(ctx context.Context, sourceID string, relType string) ([]*Relationship, error)
- func (r *RelationshipsRepository) FindByTarget(ctx context.Context, targetID string, relType string) ([]*Relationship, error)
- func (r *RelationshipsRepository) Get(ctx context.Context, id string) (*Relationship, error)
- func (r *RelationshipsRepository) List(ctx context.Context, relType string) ([]*Relationship, error)
- func (r *RelationshipsRepository) Update(ctx context.Context, rel *Relationship) error
- type SyncState
- type TaskFilter
Constants ¶
const ( ObjectTypeCompany = "Company" ObjectTypeContact = "Contact" ObjectTypeDeal = "Deal" )
Object type constants for CRM entities.
const ( RelTypeWorksAt = "works_at" RelTypeDealContact = "deal_contact" RelTypeDealCompany = "deal_company" RelTypeKnows = "knows" )
Relationship type constants for CRM relationships.
Variables ¶
var ( ErrObjectNotFound = errors.New("object not found") ErrInvalidObject = errors.New("invalid object") )
var ( ErrRelationshipNotFound = errors.New("relationship not found") ErrInvalidRelationship = errors.New("invalid relationship") )
Functions ¶
func CheckSyncLogExists ¶
CheckSyncLogExists checks if an entity has already been imported.
func CreateContactCadence ¶
func CreateContactCadence(db *sql.DB, cadence *models.ContactCadence) error
CreateContactCadence creates or updates a contact's follow-up cadence.
func CreateRelationship ¶
func CreateRelationship(db *sql.DB, relationship *models.Relationship) error
func CreateSyncLog ¶
func CreateSyncLog(db *sql.DB, id, sourceService, sourceID, entityType, entityID, metadata string) error
CreateSyncLog creates a sync log entry for an imported entity.
func CreateTask ¶
func CreateTask(db *sql.DB, task *objects.TaskObject) error
CreateTask inserts a new task into the database.
func DeleteTask ¶
DeleteTask removes a task from the database.
func FindCompanies ¶
func FindContacts ¶
func GetAllRelationships ¶
func GetAllRelationships(db *sql.DB) ([]models.Relationship, error)
func GetContactCadence ¶
GetContactCadence retrieves cadence info for a contact.
func GetContactRelationships ¶
func GetFollowupList ¶
GetFollowupList returns contacts needing follow-up, sorted by priority.
func GetInteractionHistory ¶
func GetInteractionHistory(db *sql.DB, contactID uuid.UUID, limit int) ([]models.InteractionLog, error)
GetInteractionHistory retrieves interaction history for a contact.
func GetRecentInteractions ¶
GetRecentInteractions gets all recent interactions across all contacts.
func GetRelationship ¶
func GetRelationshipsBetween ¶
func InitSchema ¶
func ListDueSoonTasks ¶
ListDueSoonTasks returns tasks due within the specified number of days.
func ListOverdueTasks ¶
func ListOverdueTasks(db *sql.DB) ([]*objects.TaskObject, error)
ListOverdueTasks returns all overdue tasks.
func ListTasks ¶
func ListTasks(db *sql.DB, filter *TaskFilter) ([]*objects.TaskObject, error)
ListTasks retrieves tasks with optional filtering.
func ListTasksByRelatedRecord ¶
ListTasksByRelatedRecord returns tasks linked to a specific record.
func LogInteraction ¶
func LogInteraction(db *sql.DB, interaction *models.InteractionLog) error
LogInteraction records a new interaction and updates contact cadence.
func ObjectToCompany ¶
ObjectToCompany converts an Office OS Object to a models.Company.
func ObjectToContact ¶
ObjectToContact converts an Office OS Object to a models.Contact.
func ObjectToDeal ¶
ObjectToDeal converts an Office OS Object to a models.Deal.
func SetContactCadence ¶
SetContactCadence sets or updates a contact's cadence settings.
func UpdateCadenceAfterInteraction ¶
UpdateCadenceAfterInteraction updates cadence when interaction is logged.
func UpdateRelationship ¶
func UpdateSyncStatus ¶
UpdateSyncStatus updates the sync status for a service.
func UpdateSyncToken ¶
UpdateSyncToken updates the sync token and last sync time for a service.
func UpdateTask ¶
func UpdateTask(db *sql.DB, task *objects.TaskObject) error
UpdateTask updates an existing task.
Types ¶
type Object ¶
type Object struct {
ID string `json:"id"`
Kind string `json:"kind"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy string `json:"created_by"`
ACL string `json:"acl"` // JSON string
Tags string `json:"tags"` // JSON string
Fields map[string]interface{} `json:"fields"`
}
Object represents the core entity in Office OS.
func CompanyToObject ¶
CompanyToObject converts a models.Company to an Office OS Object.
func ContactToObject ¶
ContactToObject converts a models.Contact to an Office OS Object.
func DealToObject ¶
DealToObject converts a models.Deal to an Office OS Object.
type ObjectsRepository ¶
type ObjectsRepository struct {
// contains filtered or unexported fields
}
ObjectsRepository provides CRUD operations for Office OS objects.
func NewObjectsRepository ¶
func NewObjectsRepository(db *sql.DB) *ObjectsRepository
NewObjectsRepository creates a new objects repository.
func (*ObjectsRepository) Create ¶
func (r *ObjectsRepository) Create(ctx context.Context, obj *Object) error
Create creates a new object in the database.
func (*ObjectsRepository) Delete ¶
func (r *ObjectsRepository) Delete(ctx context.Context, id string) error
Delete deletes an object by ID.
type Relationship ¶
type Relationship struct {
ID string `json:"id"`
SourceID string `json:"source_id"`
TargetID string `json:"target_id"`
Type string `json:"type"`
Metadata map[string]interface{} `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Relationship represents a connection between two objects.
type RelationshipsRepository ¶
type RelationshipsRepository struct {
// contains filtered or unexported fields
}
RelationshipsRepository provides CRUD operations for relationships.
func NewRelationshipsRepository ¶
func NewRelationshipsRepository(db *sql.DB) *RelationshipsRepository
NewRelationshipsRepository creates a new relationships repository.
func (*RelationshipsRepository) Create ¶
func (r *RelationshipsRepository) Create(ctx context.Context, rel *Relationship) error
Create creates a new relationship.
func (*RelationshipsRepository) Delete ¶
func (r *RelationshipsRepository) Delete(ctx context.Context, id string) error
Delete deletes a relationship by ID.
func (*RelationshipsRepository) FindBetween ¶
func (r *RelationshipsRepository) FindBetween(ctx context.Context, objectID1, objectID2 string) ([]*Relationship, error)
FindBetween retrieves all relationships between two objects (in either direction).
func (*RelationshipsRepository) FindBySource ¶
func (r *RelationshipsRepository) FindBySource(ctx context.Context, sourceID string, relType string) ([]*Relationship, error)
FindBySource retrieves all relationships originating from a source object.
func (*RelationshipsRepository) FindByTarget ¶
func (r *RelationshipsRepository) FindByTarget(ctx context.Context, targetID string, relType string) ([]*Relationship, error)
FindByTarget retrieves all relationships pointing to a target object.
func (*RelationshipsRepository) Get ¶
func (r *RelationshipsRepository) Get(ctx context.Context, id string) (*Relationship, error)
Get retrieves a relationship by ID.
func (*RelationshipsRepository) List ¶
func (r *RelationshipsRepository) List(ctx context.Context, relType string) ([]*Relationship, error)
List retrieves all relationships, optionally filtered by type.
func (*RelationshipsRepository) Update ¶
func (r *RelationshipsRepository) Update(ctx context.Context, rel *Relationship) error
Update updates an existing relationship.
type SyncState ¶
type SyncState struct {
Service string
LastSyncTime *time.Time
LastSyncToken *string
Status string
ErrorMessage *string
CreatedAt time.Time
UpdatedAt time.Time
}
SyncState represents the sync state for a service.
func GetAllSyncStates ¶
GetAllSyncStates retrieves the sync state for all services.