sqliteapi

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorCategory

type ErrorCategory string
const (
	ErrorCategoryValidation ErrorCategory = "validation"
	ErrorCategoryPermission ErrorCategory = "permission"
	ErrorCategorySyntax     ErrorCategory = "syntax"
	ErrorCategoryExecution  ErrorCategory = "execution"
	ErrorCategoryTimeout    ErrorCategory = "timeout"
)

type MetadataStore

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

func NewMetadataStore

func NewMetadataStore(runtime *sqliteapp.Runtime) (*MetadataStore, error)

func (*MetadataStore) CreateSavedQuery

func (s *MetadataStore) CreateSavedQuery(ctx context.Context, req SavedQueryUpsertRequest) (*SavedQuery, error)

func (*MetadataStore) DeleteSavedQuery

func (s *MetadataStore) DeleteSavedQuery(ctx context.Context, id string) error

func (*MetadataStore) ListQueryHistory

func (s *MetadataStore) ListQueryHistory(ctx context.Context, limit, offset int, status string) ([]QueryHistoryEntry, int, error)

func (*MetadataStore) ListSavedQueries

func (s *MetadataStore) ListSavedQueries(ctx context.Context) ([]SavedQuery, error)

func (*MetadataStore) RecordQueryHistory

func (s *MetadataStore) RecordQueryHistory(ctx context.Context, entry QueryHistoryEntry) error

func (*MetadataStore) UpdateSavedQuery

func (s *MetadataStore) UpdateSavedQuery(ctx context.Context, id string, req SavedQueryUpsertRequest) (*SavedQuery, error)

type QueryAPIError

type QueryAPIError struct {
	Category      ErrorCategory `json:"category"`
	Message       string        `json:"message"`
	CorrelationID string        `json:"correlation_id"`
}

type QueryAuditEvent

type QueryAuditEvent struct {
	CorrelationID string
	Status        string
	Category      string
	StatementType string
	DurationMS    int64
	RowCount      int
	Truncated     bool
}

type QueryColumn

type QueryColumn struct {
	Name         string `json:"name"`
	DatabaseType string `json:"database_type,omitempty"`
	ScanType     string `json:"scan_type,omitempty"`
	Nullable     *bool  `json:"nullable,omitempty"`
}

type QueryErrorResponse

type QueryErrorResponse struct {
	Error QueryAPIError `json:"error"`
}

type QueryExecutionMeta

type QueryExecutionMeta struct {
	CorrelationID       string `json:"correlation_id"`
	DurationMS          int64  `json:"duration_ms"`
	RowCount            int    `json:"row_count"`
	EffectiveRowLimit   int    `json:"effective_row_limit"`
	PayloadBytes        int    `json:"payload_bytes"`
	PayloadCapBytes     int    `json:"payload_cap_bytes"`
	StatementTimeoutMS  int64  `json:"statement_timeout_ms"`
	Truncated           bool   `json:"truncated"`
	TruncatedByRowLimit bool   `json:"truncated_by_row_limit"`
	TruncatedByPayload  bool   `json:"truncated_by_payload"`
	StatementType       string `json:"statement_type"`
}

type QueryExecutionResult

type QueryExecutionResult struct {
	Response       QueryResponse
	Duration       time.Duration
	StatementType  string
	TruncatedRows  bool
	TruncatedBytes bool
}

type QueryExecutor

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

func NewQueryExecutor

func NewQueryExecutor(runtime *sqliteapp.Runtime, opts QueryExecutorOptions) (*QueryExecutor, error)

func (*QueryExecutor) Execute

func (q *QueryExecutor) Execute(ctx context.Context, req QueryRequest, correlationID string) (*QueryExecutionResult, error)

type QueryExecutorOptions

type QueryExecutorOptions struct {
	MaxPayloadBytes      int
	StatementAllowlist   []string
	StatementDenylist    []string
	RedactedColumns      []string
	RateLimitRequests    int
	RateLimitWindow      time.Duration
	EnableAuditLogEvents bool
}

type QueryHandler

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

func NewQueryHandler

func NewQueryHandler(executor *QueryExecutor, store *MetadataStore, logger *log.Logger) (*QueryHandler, error)

func (*QueryHandler) HandleHistory

func (h *QueryHandler) HandleHistory(w http.ResponseWriter, req *http.Request)

func (*QueryHandler) HandleQuery

func (h *QueryHandler) HandleQuery(w http.ResponseWriter, req *http.Request)

func (*QueryHandler) HandleSavedQueries

func (h *QueryHandler) HandleSavedQueries(w http.ResponseWriter, req *http.Request)

func (*QueryHandler) HandleSavedQueryByID

func (h *QueryHandler) HandleSavedQueryByID(w http.ResponseWriter, req *http.Request)

type QueryHandlerOptions

type QueryHandlerOptions struct {
	RateLimitRequests    int
	RateLimitWindow      time.Duration
	EnableAuditLogEvents bool
}

type QueryHistoryEntry

type QueryHistoryEntry struct {
	ID           string `json:"id"`
	QueryText    string `json:"query_text"`
	QueryPreview string `json:"query_preview"`
	ParamsJSON   string `json:"params_json"`
	Status       string `json:"status"`
	DurationMS   int64  `json:"duration_ms"`
	RowCount     int    `json:"row_count"`
	ErrorSummary string `json:"error_summary"`
	CreatedAt    string `json:"created_at"`
}

type QueryHistoryListResponse

type QueryHistoryListResponse struct {
	Items  []QueryHistoryEntry `json:"items"`
	Total  int                 `json:"total"`
	Limit  int                 `json:"limit"`
	Offset int                 `json:"offset"`
}

type QueryRequest

type QueryRequest struct {
	SQL                 string         `json:"sql"`
	PositionalParams    []any          `json:"positional_params,omitempty"`
	NamedParams         map[string]any `json:"named_params,omitempty"`
	RowLimit            int            `json:"row_limit,omitempty"`
	TimeoutMS           int            `json:"timeout_ms,omitempty"`
	AllowMultiStatement bool           `json:"allow_multi_statement,omitempty"`
}

type QueryResponse

type QueryResponse struct {
	Columns []QueryColumn      `json:"columns"`
	Rows    []map[string]any   `json:"rows"`
	Meta    QueryExecutionMeta `json:"meta"`
}

type SavedQuery

type SavedQuery struct {
	ID               string         `json:"id"`
	Name             string         `json:"name"`
	SQL              string         `json:"sql"`
	PositionalParams []any          `json:"positional_params,omitempty"`
	NamedParams      map[string]any `json:"named_params,omitempty"`
	SchemaVersion    int            `json:"schema_version"`
	CreatedAt        string         `json:"created_at"`
	UpdatedAt        string         `json:"updated_at"`
}

type SavedQueryListResponse

type SavedQueryListResponse struct {
	Items []SavedQuery `json:"items"`
}

type SavedQueryUpsertRequest

type SavedQueryUpsertRequest struct {
	Name             string         `json:"name"`
	SQL              string         `json:"sql"`
	PositionalParams []any          `json:"positional_params,omitempty"`
	NamedParams      map[string]any `json:"named_params,omitempty"`
	SchemaVersion    int            `json:"schema_version,omitempty"`
}

Jump to

Keyboard shortcuts

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