store

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CL_DEFAULT_ID = ChangelogID("cl_config")
	GH_DEFAULT_ID = GHSourceID("gh_config")
	WS_DEFAULT_ID = WorkspaceID("ws_config")
)

Variables

This section is empty.

Functions

func IsGHID

func IsGHID(id string) bool

Types

type Changelog

type Changelog struct {
	WorkspaceID WorkspaceID
	ID          ChangelogID
	Subdomain   Subdomain
	Domain      Domain
	Title       apitypes.NullString
	Subtitle    apitypes.NullString
	LogoSrc     apitypes.NullString
	LogoLink    apitypes.NullString
	LogoAlt     apitypes.NullString
	LogoHeight  apitypes.NullString
	LogoWidth   apitypes.NullString
	ColorScheme ColorScheme
	CreatedAt   time.Time
	GHSource    null.Value[GHSource]
	LocalSource null.Value[LocalSource]
}

type ChangelogID

type ChangelogID string

func NewCID

func NewCID() ChangelogID

func ParseCID

func ParseCID(id string) (ChangelogID, error)

func (ChangelogID) String

func (i ChangelogID) String() string

type ColorScheme added in v0.1.5

type ColorScheme int
const (
	System ColorScheme = 1
	Light  ColorScheme = 2
	Dark   ColorScheme = 3
)

func NewColorScheme added in v0.1.5

func NewColorScheme(cs apitypes.ColorScheme) ColorScheme

func (*ColorScheme) Scan added in v0.1.5

func (cs *ColorScheme) Scan(value interface{}) error

func (ColorScheme) String added in v0.1.5

func (cs ColorScheme) String() string

func (ColorScheme) ToApiTypes added in v0.1.5

func (cs ColorScheme) ToApiTypes() apitypes.ColorScheme

func (ColorScheme) Value added in v0.1.5

func (cs ColorScheme) Value() (driver.Value, error)

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Domain added in v0.1.2

type Domain apitypes.NullString

func ParseDomain added in v0.1.2

func ParseDomain(domain string) (Domain, error)

strips everything from domain except the host

func ParseDomainNullString added in v0.1.4

func ParseDomainNullString(ns apitypes.NullString) (Domain, error)

if ns is valid, it parses the domain by stripping everything except the host from the string.

func (Domain) NullString added in v0.1.4

func (d Domain) NullString() apitypes.NullString

func (Domain) String added in v0.1.4

func (d Domain) String() string

type GHSource

type GHSource struct {
	ID             GHSourceID
	WorkspaceID    WorkspaceID
	Owner          string
	Repo           string
	Path           string
	InstallationID int64
}

type GHSourceID

type GHSourceID string

func NewGHID

func NewGHID() GHSourceID

func ParseGHID

func ParseGHID(id string) (GHSourceID, error)

func (GHSourceID) String

func (i GHSourceID) String() string

type LocalSource

type LocalSource struct {
	Path string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Store

type Store interface {
	GetChangelog(context.Context, WorkspaceID, ChangelogID) (Changelog, error)
	GetChangelogByDomainOrSubdomain(ctx context.Context, domain Domain, subdomain Subdomain) (Changelog, error)
	ListChangelogs(context.Context, WorkspaceID) ([]Changelog, error)
	CreateChangelog(context.Context, Changelog) (Changelog, error)
	UpdateChangelog(context.Context, WorkspaceID, ChangelogID, UpdateChangelogArgs) (Changelog, error)
	DeleteChangelog(context.Context, WorkspaceID, ChangelogID) error
	SetChangelogGHSource(context.Context, WorkspaceID, ChangelogID, GHSourceID) error
	DeleteChangelogSource(context.Context, WorkspaceID, ChangelogID) error

	// Workspace
	GetWorkspace(context.Context, WorkspaceID) (Workspace, error)
	SaveWorkspace(context.Context, Workspace) (Workspace, error)
	GetWorkspaceIDByToken(ctx context.Context, token string) (WorkspaceID, error)
	DeleteWorkspace(context.Context, WorkspaceID) error

	// Source
	CreateGHSource(context.Context, GHSource) (GHSource, error)
	GetGHSource(context.Context, WorkspaceID, GHSourceID) (GHSource, error)
	ListGHSources(context.Context, WorkspaceID) ([]GHSource, error)
	DeleteGHSource(context.Context, WorkspaceID, GHSourceID) error
}

func NewConfigStore

func NewConfigStore(cfg config.Config) Store

Create a new store implementation, backed by the config file

func NewSQLiteStore

func NewSQLiteStore(conn string) (Store, error)

type Subdomain added in v0.1.2

type Subdomain string

func NewSubdomain added in v0.1.2

func NewSubdomain(workspaceName string) Subdomain

func SubdomainFromHost added in v0.1.2

func SubdomainFromHost(host string) (Subdomain, error)

Returns the subdomain from the host. Returns an error if the host doesn't have a subdomain

func (Subdomain) NullString added in v0.1.2

func (s Subdomain) NullString() apitypes.NullString

func (Subdomain) String added in v0.1.2

func (s Subdomain) String() string

type Token

type Token string

func NewToken

func NewToken() Token

func ParseToken

func ParseToken(key string) (Token, error)

func (Token) IsSet

func (k Token) IsSet() bool

func (Token) String

func (k Token) String() string

type UpdateChangelogArgs

type UpdateChangelogArgs struct {
	Title       apitypes.NullString
	Subdomain   apitypes.NullString
	Domain      Domain
	Subtitle    apitypes.NullString
	LogoSrc     apitypes.NullString
	LogoLink    apitypes.NullString
	LogoAlt     apitypes.NullString
	LogoHeight  apitypes.NullString
	LogoWidth   apitypes.NullString
	ColorScheme ColorScheme
}

type Workspace

type Workspace struct {
	ID    WorkspaceID
	Name  string
	Token Token
}

type WorkspaceID

type WorkspaceID string

func NewWID

func NewWID() WorkspaceID

func ParseWID

func ParseWID(id string) (WorkspaceID, error)

func (WorkspaceID) String

func (i WorkspaceID) String() string

Jump to

Keyboard shortcuts

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