utils

package
v0.0.0-...-7f6939c Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogCampaignAuditEvent

func LogCampaignAuditEvent(ctx context.Context, exec store.Querier, auditLogStore store.AuditLogStore, campaign *models.LeadGenerationCampaign, action, description string)

LogCampaignAuditEvent logs an audit event for a campaign using the consolidated logger

func WithOptionalTransaction

func WithOptionalTransaction(ctx context.Context, db *sqlx.DB, isSQL bool, operationName string, fn func(store.Querier) error) error

WithOptionalTransaction executes a function with an optional transaction based on isSQL flag

func WithSQLTransactionIfSQL

func WithSQLTransactionIfSQL(ctx context.Context, db *sqlx.DB, isSQL bool, operationName string, fn func(store.Querier) error) error

WithSQLTransactionIfSQL executes a function within a SQL transaction if in SQL mode

Types

type AuditLogger

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

AuditLogger provides common audit logging functionality

func NewAuditLogger

func NewAuditLogger(auditLogStore store.AuditLogStore) *AuditLogger

NewAuditLogger creates a new audit logger

func (*AuditLogger) LogCampaignEvent

func (al *AuditLogger) LogCampaignEvent(ctx context.Context, exec store.Querier, campaign *models.LeadGenerationCampaign, action, description string)

LogCampaignEvent logs an audit event for a campaign

func (*AuditLogger) LogGenericEvent

func (al *AuditLogger) LogGenericEvent(ctx context.Context, exec store.Querier, userID *uuid.UUID, action, entityType string, entityID *uuid.UUID, details map[string]string)

LogGenericEvent logs a generic audit event

func (*AuditLogger) LogPersonaEvent

func (al *AuditLogger) LogPersonaEvent(ctx context.Context, exec store.Querier, persona *models.Persona, userID *uuid.UUID, action, description string)

LogPersonaEvent logs an audit event for a persona

type JobCreator

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

JobCreator provides common job creation functionality for campaigns

func NewJobCreator

func NewJobCreator(campaignJobStore store.CampaignJobStore) *JobCreator

NewJobCreator creates a new job creator

func (*JobCreator) CreateInitialJob

func (jc *JobCreator) CreateInitialJob(ctx context.Context, exec store.Querier, campaign *models.LeadGenerationCampaign, jobType models.JobTypeEnum) error

CreateInitialJob creates an initial job for a campaign

type PersonaValidator

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

PersonaValidator provides common persona validation functionality

func NewPersonaValidator

func NewPersonaValidator(personaStore store.PersonaStore) *PersonaValidator

NewPersonaValidator creates a new persona validator

func (*PersonaValidator) ValidatePersonaID

func (pv *PersonaValidator) ValidatePersonaID(ctx context.Context, querier store.Querier, personaID uuid.UUID, expectedType models.PersonaTypeEnum) (*models.Persona, error)

ValidatePersonaID validates a single persona ID

func (*PersonaValidator) ValidatePersonaIDs

func (pv *PersonaValidator) ValidatePersonaIDs(ctx context.Context, querier store.Querier, personaIDs []uuid.UUID, expectedType models.PersonaTypeEnum) error

ValidatePersonaIDs validates that all provided persona IDs exist, are enabled, and match the expected type

type QueryBuilder

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

QueryBuilder helps build SQL queries with filters, ordering, and pagination

func NewQueryBuilder

func NewQueryBuilder(baseQuery string, args ...interface{}) *QueryBuilder

NewQueryBuilder creates a new query builder with a base query

func (*QueryBuilder) AddFilter

func (qb *QueryBuilder) AddFilter(condition string, value interface{}) *QueryBuilder

AddFilter adds a WHERE condition if the value is not empty

func (*QueryBuilder) AddOrdering

func (qb *QueryBuilder) AddOrdering(orderBy string) *QueryBuilder

AddOrdering adds ORDER BY clause

func (*QueryBuilder) AddPagination

func (qb *QueryBuilder) AddPagination(limit, offset int) *QueryBuilder

AddPagination adds LIMIT and OFFSET if provided

func (*QueryBuilder) Build

func (qb *QueryBuilder) Build() (string, []interface{})

Build returns the final query and arguments

func (*QueryBuilder) ExecuteQuery

func (qb *QueryBuilder) ExecuteQuery(ctx context.Context, exec store.Querier, results interface{}) error

ExecuteQuery executes the built query and returns results

type TransactionManager

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

TransactionManager handles common SQL transaction patterns

func NewTransactionManager

func NewTransactionManager(db *sqlx.DB) *TransactionManager

NewTransactionManager creates a new transaction manager

func (*TransactionManager) WithTransaction

func (tm *TransactionManager) WithTransaction(ctx context.Context, operationName string, fn func(store.Querier) error) error

WithTransaction executes a function within a SQL transaction if SQL mode is enabled

type TransactionResult

type TransactionResult struct {
	Success bool
	Error   error
}

TransactionResult contains the result of executing a function within a transaction

Jump to

Keyboard shortcuts

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