data

package
v0.0.0-...-d18dbcb Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunMigrations

func RunMigrations(ctx context.Context, db *sql.DB) error

Types

type APIKeyAuthRecord

type APIKeyAuthRecord struct {
	Key         APIKeyRecord
	Application ApplicationRecord
}

type APIKeyRecord

type APIKeyRecord struct {
	ID            string
	ApplicationID string
	Name          string
	KeyPrefix     string
	KeyHash       string
	CanRead       bool
	CanWrite      bool
	CanDelete     bool
	CreatedAt     time.Time
	LastUsedAt    *time.Time
	RevokedAt     *time.Time
}

type Adapter

type Adapter interface {
	Name() string
	DriverName() string
	DefaultDSN() string
	NormalizeDSN(input string) string
}

func Open

func Open(config Config) (*sql.DB, Adapter, error)

func ResolveAdapter

func ResolveAdapter(name string) (Adapter, error)

type ApplicationRecord

type ApplicationRecord struct {
	ID          string
	OwnerUserID string
	Name        string
	Description string
	GitHubLink  string
	Domain      string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type BrowserSessionRecord

type BrowserSessionRecord struct {
	ID                string
	ApplicationID     string
	ExternalBrowserID string
	Status            string
	CDPURL            string
	CDPHTTPURL        string
	Headless          bool
	SpawnTaskProcess  string
	SpawnedByWorkerID *int
	CreatedAt         time.Time
	LastActiveAt      time.Time
	IdleTimeout       int
	ExpiresAt         time.Time
	ClosedAt          *time.Time
}

type Config

type Config struct {
	Driver       string
	DSN          string
	MaxOpenConns int
	MaxIdleConns int
}

func DefaultConfig

func DefaultConfig() Config

type PostgresAdapter

type PostgresAdapter struct{}

func (PostgresAdapter) DefaultDSN

func (PostgresAdapter) DefaultDSN() string

func (PostgresAdapter) DriverName

func (PostgresAdapter) DriverName() string

func (PostgresAdapter) Name

func (PostgresAdapter) Name() string

func (PostgresAdapter) NormalizeDSN

func (PostgresAdapter) NormalizeDSN(input string) string

type SQLiteAdapter

type SQLiteAdapter struct{}

func (SQLiteAdapter) DefaultDSN

func (SQLiteAdapter) DefaultDSN() string

func (SQLiteAdapter) DriverName

func (SQLiteAdapter) DriverName() string

func (SQLiteAdapter) Name

func (SQLiteAdapter) Name() string

func (SQLiteAdapter) NormalizeDSN

func (SQLiteAdapter) NormalizeDSN(input string) string

type SessionRecord

type SessionRecord struct {
	ID        string
	UserID    string
	TokenHash string
	ExpiresAt time.Time
	CreatedAt time.Time
}

type Store

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

func NewStore

func NewStore(db *sql.DB) *Store

func (*Store) CountUsers

func (s *Store) CountUsers(ctx context.Context) (int, error)

func (*Store) CreateAPIKey

func (s *Store) CreateAPIKey(ctx context.Context, record APIKeyRecord) error

func (*Store) CreateApplication

func (s *Store) CreateApplication(ctx context.Context, record ApplicationRecord) error

func (*Store) CreateBrowserSession

func (s *Store) CreateBrowserSession(ctx context.Context, record BrowserSessionRecord) error

func (*Store) CreateSession

func (s *Store) CreateSession(ctx context.Context, record SessionRecord) error

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, record UserRecord) error

func (*Store) DeleteExpiredSessions

func (s *Store) DeleteExpiredSessions(ctx context.Context, now time.Time) error

func (*Store) DeleteSessionByTokenHash

func (s *Store) DeleteSessionByTokenHash(ctx context.Context, tokenHash string) error

func (*Store) GetActiveAPIKeyAuthByHash

func (s *Store) GetActiveAPIKeyAuthByHash(ctx context.Context, keyHash string) (APIKeyAuthRecord, bool, error)

func (*Store) GetApplicationByID

func (s *Store) GetApplicationByID(ctx context.Context, applicationID string) (ApplicationRecord, bool, error)

func (*Store) GetBrowserSessionByExternalID

func (s *Store) GetBrowserSessionByExternalID(ctx context.Context, applicationID string, externalBrowserID string) (BrowserSessionRecord, bool, error)

func (*Store) GetSessionWithUserByTokenHash

func (s *Store) GetSessionWithUserByTokenHash(ctx context.Context, tokenHash string) (SessionRecord, UserRecord, bool, error)

func (*Store) GetUserByEmail

func (s *Store) GetUserByEmail(ctx context.Context, email string) (UserRecord, bool, error)

func (*Store) GetUserByID

func (s *Store) GetUserByID(ctx context.Context, userID string) (UserRecord, bool, error)

func (*Store) ListAPIKeysByApplicationID

func (s *Store) ListAPIKeysByApplicationID(ctx context.Context, applicationID string) ([]APIKeyRecord, error)

func (*Store) ListApplicationsByUserID

func (s *Store) ListApplicationsByUserID(ctx context.Context, userID string) ([]ApplicationRecord, error)

func (*Store) ListBrowserSessionsByApplicationID

func (s *Store) ListBrowserSessionsByApplicationID(ctx context.Context, applicationID string) ([]BrowserSessionRecord, error)

func (*Store) ListBrowserSessionsByUserID

func (s *Store) ListBrowserSessionsByUserID(ctx context.Context, userID string, limit int) ([]BrowserSessionRecord, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context, limit int) ([]UserRecord, error)

func (*Store) MarkBrowserSessionCompleted

func (s *Store) MarkBrowserSessionCompleted(ctx context.Context, applicationID string, externalBrowserID string, closedAt time.Time) error

func (*Store) RevokeAPIKey

func (s *Store) RevokeAPIKey(ctx context.Context, applicationID string, keyID string, revokedAt time.Time) (bool, error)

func (*Store) TouchAPIKeyLastUsed

func (s *Store) TouchAPIKeyLastUsed(ctx context.Context, keyID string, usedAt time.Time) error

func (*Store) UpdateBrowserSessionHeartbeat

func (s *Store) UpdateBrowserSessionHeartbeat(ctx context.Context, applicationID string, externalBrowserID string, updated BrowserSessionRecord) error

type UserRecord

type UserRecord struct {
	ID           string
	Email        string
	PasswordHash string
	Role         string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

Jump to

Keyboard shortcuts

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