storage

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTempProjects

func CleanupTempProjects() error

CleanupTempProjects removes all temporary projects

func ClearConfig

func ClearConfig() error

ClearConfig removes the configuration file

func ClearSession

func ClearSession() error

ClearSession removes the session file

func ComputeFileHash

func ComputeFileHash(filePath string) (string, error)

ComputeFileHash computes SHA256 hash of a file

func ConfigExists

func ConfigExists() (bool, error)

ConfigExists checks if the config file exists

func DeleteConversation added in v0.3.0

func DeleteConversation(projectID, conversationID string) error

DeleteConversation deletes a conversation and all its messages

func DeleteProject

func DeleteProject(project *Project) error

DeleteProject deletes a project from disk

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the octrafic config directory

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the full path to the config file

func GetConversationPath added in v0.3.0

func GetConversationPath(projectID, conversationID string) (string, error)

GetConversationPath returns the path to a conversation database file

func GetEndpointsList

func GetEndpointsList(endpoints []parser.Endpoint) string

GetEndpointsList returns comma-separated list of endpoints for system prompt Format: "GET /users, POST /users, GET /users/{id}, PUT /users/{id}, DELETE /users/{id}, GET /health"

func GetProjectPathByType

func GetProjectPathByType(projectID string, isTemporary bool) (string, error)

GetProjectPathByType returns the path to a specific project directory based on type

func GetProjectsDir

func GetProjectsDir() (string, error)

GetProjectsDir returns the path to the projects directory

func GetSessionPath

func GetSessionPath() (string, error)

GetSessionPath returns the path to the session file

func GetTempProjectsDir

func GetTempProjectsDir() (string, error)

GetTempProjectsDir returns the path to the temporary projects directory

func HasEndpoints

func HasEndpoints(projectID string, isTemporary bool) bool

HasEndpoints checks if endpoints.json exists for a project

func Load

func Load() (*analyzer.Analysis, error)

func LoadEndpoints

func LoadEndpoints(projectID string, isTemporary bool) ([]parser.Endpoint, error)

LoadEndpoints loads endpoints from endpoints.json

func LoadOrParseSpec

func LoadOrParseSpec(specPath, projectID, baseURL, apiKey string, isTemporary bool) ([]parser.Endpoint, string, error)

LoadOrParseSpec parses the spec file and returns endpoints with hash Now uses endpoints.json storage instead of Bleve index

func SaveConfig

func SaveConfig(config *Config) error

SaveConfig saves the configuration to disk with secure permissions

func SaveEndpoints

func SaveEndpoints(projectID string, endpoints []parser.Endpoint, isTemporary bool) error

SaveEndpoints saves parsed endpoints to endpoints.json

func SaveMessage added in v0.3.0

func SaveMessage(projectID, conversationID, messageType, content string, metadata map[string]interface{}) error

SaveMessage saves a message to the conversation

func SaveProject

func SaveProject(project *Project) error

SaveProject saves a project to disk

func SaveSession

func SaveSession(session *Session) error

SaveSession saves the session to disk

func SessionExists

func SessionExists() bool

SessionExists checks if a session file exists

func Store

func Store(analysis *analyzer.Analysis) error

func ValidateSpecPath

func ValidateSpecPath(specPath string) error

ValidateSpecPath checks if spec file exists and is readable

Types

type AuthConfig

type AuthConfig struct {
	Type     string `json:"type"`                // none, bearer, apikey, basic
	Token    string `json:"token,omitempty"`     // Bearer token
	KeyName  string `json:"key_name,omitempty"`  // API key name (e.g., X-API-Key)
	KeyValue string `json:"key_value,omitempty"` // API key value
	Location string `json:"location,omitempty"`  // header or query
	Username string `json:"username,omitempty"`  // Basic auth username
	Password string `json:"password,omitempty"`  // Basic auth password
}

AuthConfig stores authentication configuration for a project WARNING: Credentials are stored in plain text

type Config

type Config struct {
	APIKey string `json:"api_key"`
}

Config represents the CLI configuration

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the configuration from disk

type Conversation added in v0.3.0

type Conversation struct {
	ID        string    `json:"id"`
	ProjectID string    `json:"project_id"`
	Title     string    `json:"title"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Conversation represents a chat conversation for a project

func CreateConversation added in v0.3.0

func CreateConversation(projectID, conversationID, title string) (*Conversation, error)

CreateConversation creates a new conversation

func ListConversations added in v0.3.0

func ListConversations(projectID string) ([]*Conversation, error)

ListConversations returns all conversations for a project

func LoadConversation added in v0.3.0

func LoadConversation(projectID, conversationID string) (*Conversation, error)

LoadConversation loads a conversation by ID

type Message added in v0.3.0

type Message struct {
	ID             int64                  `json:"id"`
	ConversationID string                 `json:"conversation_id"`
	Type           string                 `json:"type"` // 'user', 'assistant', 'api_request', 'api_response', 'system'
	Content        string                 `json:"content"`
	Metadata       map[string]interface{} `json:"metadata,omitempty"`
	Timestamp      time.Time              `json:"timestamp"`
}

Message represents a single message in a conversation

func GetMessages added in v0.3.0

func GetMessages(projectID, conversationID string) ([]*Message, error)

GetMessages retrieves all messages from a conversation

type Project

type Project struct {
	ID             string      `json:"id"`
	Name           string      `json:"name"`
	BaseURL        string      `json:"base_url"`
	SpecPath       string      `json:"spec_path,omitempty"`
	SpecHash       string      `json:"spec_hash,omitempty"`
	IsTemporary    bool        `json:"is_temporary"`
	AuthConfig     *AuthConfig `json:"auth_config,omitempty"`
	CreatedAt      time.Time   `json:"created_at"`
	UpdatedAt      time.Time   `json:"updated_at"`
	LastAccessedAt time.Time   `json:"last_accessed_at"`
}

Project represents a single API testing project

func CheckNameConflict

func CheckNameConflict(name string, excludeProjectID string) (*Project, error)

CheckNameConflict checks if a project with the given name already exists (excluding given projectID)

func CreateOrUpdateProject

func CreateOrUpdateProject(projectID, name, baseURL, specPath, apiKey string, isTemporary bool) (*Project, []parser.Endpoint, error)

CreateOrUpdateProject creates or updates a project with spec parsing Returns the project and parsed endpoints

func FindProjectByName

func FindProjectByName(name string) (*Project, error)

FindProjectByName searches for a project by name in permanent storage

func ListNamedProjects

func ListNamedProjects() ([]*Project, error)

ListNamedProjects returns only named (non-temporary) projects

func ListProjects

func ListProjects() ([]*Project, error)

ListProjects returns all projects

func LoadProject

func LoadProject(projectID string) (*Project, error)

LoadProject loads a project from disk (checks both permanent and temporary locations)

func (*Project) ClearAuth

func (p *Project) ClearAuth()

ClearAuth removes authentication configuration from project

func (*Project) HasAuth

func (p *Project) HasAuth() bool

HasAuth returns true if project has saved authentication

type ProjectContext

type ProjectContext struct {
	Project       *Project
	ProjectPath   string
	EndpointsPath string
	HashPath      string
}

ProjectContext encapsulates project data with pre-computed paths

func LoadProjectContext

func LoadProjectContext(projectID string) (*ProjectContext, error)

LoadProjectContext loads a project and creates its context

func NewProjectContext

func NewProjectContext(project *Project) (*ProjectContext, error)

NewProjectContext creates a ProjectContext from a loaded or new project

type Session

type Session struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	UserEmail    string    `json:"user_email"`
	ExpiresAt    time.Time `json:"expires_at"`
}

Session represents a user authentication session

func LoadSession

func LoadSession() (*Session, error)

LoadSession loads the session from disk

func (*Session) IsExpired

func (s *Session) IsExpired() bool

IsExpired checks if the session is expired

Jump to

Keyboard shortcuts

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