postgres

package
v0.0.0-...-e105d0e Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TABLE_PROVIDERS = "providers"
	TABLE_PROMPTS   = "prompts"
	TABLE_APIKEYS   = "apikeys"
)

Variables

View Source
var (
	ErrDuplicateKey              = errors.New("duplicate key")
	ErrCheckViolation            = errors.New("check constraint violation")
	ErrForeignKeyViolation       = errors.New("foreign key violation")
	ErrInvalidTextRepresentation = errors.New("invalid input syntax type")
	ErrInvalidID                 = errors.New("invalid id")
)
View Source
var (
	ErrConflict = errors.New("provider already exist")
	ErrNotExist = errors.New("apikey or its relations doesn't exist")
)

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID         uuid.UUID    `db:"id"`
	Name       string       `db:"name"`
	Value      []byte       `db:"value"`
	LastUsedAt sql.NullTime `db:"last_used_at"`
	UpdatedAt  time.Time    `db:"updated_at"`
	CreatedAt  time.Time    `db:"created_at"`
}

func (APIKey) ToAPIKey

func (c APIKey) ToAPIKey() (apikey.APIKey, error)

type APIKeyRepository

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

func NewAPIKeyRepository

func NewAPIKeyRepository(dbc *database.Client) *APIKeyRepository

func (*APIKeyRepository) Create

func (ak *APIKeyRepository) Create(ctx context.Context, key apikey.APIKey) (apikey.APIKey, error)

func (*APIKeyRepository) DeleteByID

func (c *APIKeyRepository) DeleteByID(ctx context.Context, id string) error

func (*APIKeyRepository) Get

func (*APIKeyRepository) GetAll

func (c *APIKeyRepository) GetAll(ctx context.Context) ([]apikey.APIKey, error)

func (*APIKeyRepository) GetByToken

func (c *APIKeyRepository) GetByToken(ctx context.Context, token string) (apikey.APIKey, error)

func (*APIKeyRepository) Update

type Crypto

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

func NewCrypto

func NewCrypto(key *[32]byte) *Crypto

func (*Crypto) Decrypt

func (e *Crypto) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt decrypts a string

func (*Crypto) Encrypt

func (e *Crypto) Encrypt(plaintext []byte) ([]byte, error)

Encrypt encrypts a string

type CryptoNoop

type CryptoNoop struct{}

func (*CryptoNoop) Decrypt

func (e *CryptoNoop) Decrypt(ciphertext []byte) ([]byte, error)

func (*CryptoNoop) Encrypt

func (e *CryptoNoop) Encrypt(plaintext []byte) ([]byte, error)

type Encryptor

type Encryptor interface {
	Encrypt(plaintext []byte) ([]byte, error)
	Decrypt(ciphertext []byte) ([]byte, error)
}

type PromptDB

type PromptDB struct {
	ID          uuid.UUID `db:"id"`
	Name        string    `db:"name"`
	Description string    `db:"description"`
	Template    string    `db:"template"`
	Metadata    []byte    `db:"metadata"`
	UpdatedAt   time.Time `db:"updated_at"`
	CreatedAt   time.Time `db:"created_at"`
}

func (PromptDB) ToPrompt

func (c PromptDB) ToPrompt() (prompt.Prompt, error)

type PromptRepository

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

func NewPromptRepository

func NewPromptRepository(dbc *database.Client) *PromptRepository

func (*PromptRepository) DeleteByID

func (*PromptRepository) DeleteByID(ctx context.Context, connID uuid.UUID) error

func (*PromptRepository) GetAll

func (c *PromptRepository) GetAll(ctx context.Context) ([]prompt.Prompt, error)

func (*PromptRepository) GetByID

func (*PromptRepository) GetByID(ctx context.Context, connID uuid.UUID) (prompt.Prompt, error)

func (*PromptRepository) GetByName

func (c *PromptRepository) GetByName(ctx context.Context, name string) (prompt.Prompt, error)

func (*PromptRepository) Upsert

func (c *PromptRepository) Upsert(ctx context.Context, conn prompt.Prompt) (prompt.Prompt, error)

type ProviderDB

type ProviderDB struct {
	ID        uuid.UUID `db:"id"`
	Name      string    `db:"name"`
	Config    []byte    `db:"config"`
	UpdatedAt time.Time `db:"updated_at"`
	CreatedAt time.Time `db:"created_at"`
}

func (ProviderDB) ToProvider

func (c ProviderDB) ToProvider() (provider.Provider, error)

type ProviderRepository

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

func NewProviderRepository

func NewProviderRepository(dbc *database.Client) *ProviderRepository

func (*ProviderRepository) DeleteByID

func (*ProviderRepository) DeleteByID(ctx context.Context, connID uuid.UUID) error

func (*ProviderRepository) GetAll

func (*ProviderRepository) GetByID

func (*ProviderRepository) GetByID(ctx context.Context, connID uuid.UUID) (provider.Provider, error)

func (*ProviderRepository) GetByName

func (c *ProviderRepository) GetByName(ctx context.Context, name string) (provider.Provider, error)

func (*ProviderRepository) Upsert

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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