models

package
v0.12.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package models provides domain entities.

Package models provides domain entities.

Index

Constants

View Source
const (
	MessageTypeDefault = iota
	MessageTypeThread
	MessageTypeEphemeral
)

Message types of published messages.

View Source
const (
	StatusRunning = "running"
	StatusError   = "error"
	StatusOK      = "ok"
)

Message status.

View Source
const ChatAppendSeparator = "\n\n"

ChatAppendSeparator separates appended part of a message.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audit

type Audit struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	RealName string `json:"realName"`
	Command  string `json:"command"`
	Query    string `json:"query"`
}

Audit represents audit log actions.

type Clone

type Clone struct {
	Name     string
	Host     string
	Port     string
	Username string
	Password string
	SSLMode  string
}

Clone contains connection info of a clone.

func (Clone) ConnectionString

func (clone Clone) ConnectionString() string

type CommandResult

type CommandResult struct {
	SessionID         string `json:"session_id"`
	Command           string `json:"command"`
	Query             string `json:"query"`
	PlanText          string `json:"plan_text"`
	PlanExecutionText string `json:"plan_execution_text"`
	Error             string `json:"error"`
	CreatedAt         string `json:"created_at"`
	Response          string `json:"response"`
	PlanJSON          string `json:"plan_json"`
	PlanExecutionJSON string `json:"plan_execution_json"`
	QueryLocks        string `json:"query_locks"`
}

CommandResult represents the result of the running command.

type IncomingMessage

type IncomingMessage struct {
	SubType     string
	Text        string
	SnippetURL  string
	ChannelID   string
	ChannelType string
	UserID      string
	Timestamp   string
	ThreadID    string
	CommandID   string
	SessionID   string
	Direct      bool
}

IncomingMessage defines a standard representation of incoming events.

type Message

type Message struct {
	MessageID   string
	CommandID   string
	SessionID   string
	MessageType int
	Status      MessageStatus
	ChannelID   string
	ThreadID    string
	UserID      string
	Text        string
	CreatedAt   time.Time
	NotifyAt    time.Time
}

Message struct defines an output message.

func NewMessage

func NewMessage(incomingMessage IncomingMessage) *Message

NewMessage creates a new message.

func (*Message) AppendText

func (m *Message) AppendText(text string)

AppendText appends a new string to the current text throw a chat append separator.

func (*Message) IsPublished

func (m *Message) IsPublished() bool

IsPublished checks if the message is already published.

func (*Message) SetMessageType

func (m *Message) SetMessageType(messageType int)

SetMessageType sets a message type.

func (*Message) SetNotifyAt

func (m *Message) SetNotifyAt(notificationTimeout time.Duration) error

SetNotifyAt sets timestamp to notify a user about the finish of a long query.

func (*Message) SetStatus

func (m *Message) SetStatus(status MessageStatus)

SetStatus sets message status.

func (*Message) SetText

func (m *Message) SetText(text string)

SetText sets text to the message.

func (*Message) SetUserID

func (m *Message) SetUserID(userID string)

SetUserID sets a user ID of the message.

type MessageStatus

type MessageStatus string

MessageStatus defines status of a message.

type RunRequest

type RunRequest struct {
	DBLabServer string `json:"dblab_server"`
	Port        int    `json:"port"`
	User        string `json:"user"`
	Password    string `json:"password"`
	SSLMode     string `json:"ssl_mode"`
	DBName      string `json:"db_name"`
	Command     string `json:"command"`
	Query       string `json:"query"`
	SessionID   string `json:"session_id"`
}

RunRequest represents run requests.

type RunResponse

type RunResponse struct {
	SessionID   string `json:"session_id"`
	CommandID   string `json:"command_id"`
	CommandLink string `json:"command_link"`
}

RunResponse represents run response.

type UserInfo

type UserInfo struct {
	ID       string
	Name     string
	RealName string
}

UserInfo struct.

Jump to

Keyboard shortcuts

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