types

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

nolint:revive

Index

Constants

View Source
const (
	AtlassianAuthorizeURL = "https://auth.atlassian.com/authorize"
	AtlassianTokenURL     = "https://auth.atlassian.com/oauth/token"

	SlackAuthorizeURL = "https://slack.com/oauth/v2/authorize"
	SlackTokenURL     = "https://slack.com/api/oauth.v2.access"

	NotionAuthorizeURL = "https://api.notion.com/v1/oauth/authorize"
	NotionTokenURL     = "https://api.notion.com/v1/oauth/token"

	HubSpotAuthorizeURL = "https://app.hubspot.com/oauth/authorize"
	HubSpotTokenURL     = "https://api.hubapi.com/oauth/v1/token"

	GoogleAuthorizeURL = "https://accounts.google.com/o/oauth2/v2/auth"
	GoogleTokenURL     = "https://oauth2.googleapis.com/token"

	GitHubAuthorizeURL = "https://github.com/login/oauth/authorize"
	GitHubTokenURL     = "https://github.com/login/oauth/access_token"

	ZoomAuthorizeURL = "https://zoom.us/oauth/authorize"
	ZoomTokenURL     = "https://zoom.us/oauth/token"

	LinkedInAuthorizeURL = "https://www.linkedin.com/oauth/v2/authorization"
	LinkedInTokenURL     = "https://www.linkedin.com/oauth/v2/accessToken"

	PagerDutyAuthorizeURL = "https://identity.pagerduty.com/oauth/authorize"
	PagerDutyTokenURL     = "https://identity.pagerduty.com/oauth/token"

	SmartThingsAuthorizeURL = "https://api.smartthings.com/oauth/authorize"
	SmartThingsTokenURL     = "https://auth-global.api.smartthings.com/oauth/token"

	GitLabAuthorizeURL = "https://gitlab.com/oauth/authorize"
	GitLabTokenURL     = "https://gitlab.com/oauth/token"
)

Variables

This section is empty.

Functions

func ConvertAPIActivity added in v0.7.1

func ConvertAPIActivity(a APIActivity) types2.APIActivity

func ConvertMCPAuditLog added in v0.8.0

func ConvertMCPAuditLog(a MCPAuditLog) types2.MCPAuditLog

ConvertMCPAuditLog converts internal MCPAuditLog to API type

func ConvertMCPUsageStats added in v0.8.0

func ConvertMCPUsageStats(s MCPUsageStatItem) types2.MCPUsageStatItem

ConvertMCPUsageStats converts internal MCPUsageStatItem to API type

func ConvertRemainingTokenUsage added in v0.8.0

func ConvertRemainingTokenUsage(userID string, r *RemainingTokenUsage) types2.RemainingTokenUsage

func ConvertTokenActivity added in v0.8.0

func ConvertTokenActivity(a RunTokenActivity) types2.TokenUsage

func ConvertUser

func ConvertUser(u *User, roleFixed bool, authProviderName string) *types2.User

func MergeOAuthAppManifests

func MergeOAuthAppManifests(r, other types.OAuthAppManifest) types.OAuthAppManifest

func ValidateAndSetDefaultsOAuthAppManifest

func ValidateAndSetDefaultsOAuthAppManifest(r *types.OAuthAppManifest, create bool) error

Types

type APIActivity added in v0.7.1

type APIActivity struct {
	ID     uint
	UserID string
	Date   time.Time
}

type AuthToken

type AuthToken struct {
	ID                    string    `json:"id" gorm:"index:idx_id_hashed_token"`
	UserID                uint      `json:"-" gorm:"index"`
	AuthProviderNamespace string    `json:"-" gorm:"index"`
	AuthProviderName      string    `json:"-" gorm:"index"`
	HashedToken           string    `json:"-" gorm:"index:idx_id_hashed_token"`
	HashedSessionID       string    `json:"-" gorm:"index"`
	CreatedAt             time.Time `json:"createdAt"`
	ExpiresAt             time.Time `json:"expiresAt"`
}

type FileScannerConfig added in v0.8.0

type FileScannerConfig struct {
	ID                uint      `json:"id" gorm:"primaryKey"`
	UpdatedAt         time.Time `json:"updatedAt"`
	ProviderName      string    `json:"providerName"`
	ProviderNamespace string    `json:"providerNamespace"`
}

type GoogleOAuthTokenResponse

type GoogleOAuthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	TokenType    string `json:"token_type"`
}

type Group added in v0.9.0

type Group struct {
	// ID is the globally unique identifier for the group.
	// Each auth provider should use a different prefix for their groups to avoid collisions with other providers.
	ID string `json:"id" gorm:"primaryKey;unique"`

	// AuthProviderName is the name of the auth provider that the group belongs to.
	// This is used to identify the auth provider that the group belongs to.
	AuthProviderName string `json:"authProviderName" gorm:"primaryKey;index:idx_group_auth_provider"`

	// AuthProviderNamespace is the namespace of the auth provider that the group belongs to.
	// Note: This is pretty much always "default", but we're keeping it here for parity with the Identity type.
	AuthProviderNamespace string `json:"authProviderNamespace" gorm:"primaryKey;index:idx_group_auth_provider"`

	// Name is the display name of the group.
	Name string `json:"name"`

	// IconURL is the URL of the group's icon.
	IconURL *string `json:"iconURL"`

	// CreatedAt is the time the group was created.
	CreatedAt time.Time `json:"createdAt" gorm:"autoCreateTime"`
}

Group represents a group that users can belong to in an auth provider.

type GroupMemberships added in v0.9.0

type GroupMemberships struct {
	// UserID is the ID of the user that is a member of the group.
	UserID uint `json:"userID" gorm:"primaryKey"`

	// GroupID is the globally unique identifier for the group.
	GroupID string `json:"groupID" gorm:"primaryKey"`

	// CreatedAt is when the group membership was created.
	CreatedAt time.Time `json:"createdAt" gorm:"autoCreateTime"`
}

GroupMemberships represents a user's membership in a group.

type Identity

type Identity struct {
	AuthProviderName      string    `json:"authProviderName" gorm:"primaryKey;index:idx_user_auth_id"`
	AuthProviderNamespace string    `json:"authProviderNamespace" gorm:"primaryKey;index:idx_user_auth_id"`
	ProviderUsername      string    `json:"providerUsername"`
	ProviderUserID        string    `json:"providerUserID"`
	HashedProviderUserID  string    `json:"hashedProviderUserID" gorm:"primaryKey"`
	Email                 string    `json:"email"`
	HashedEmail           string    `json:"hashedEmail"`
	UserID                uint      `json:"userID" gorm:"index:idx_user_auth_id"`
	IconURL               string    `json:"iconURL"`
	IconLastChecked       time.Time `json:"iconLastChecked"`
	Encrypted             bool      `json:"encrypted"`

	// AuthProviderGroupsLastChecked is the last time the identity's auth provider groups were checked.
	AuthProviderGroupsLastChecked time.Time `json:"authProviderGroupsLastChecked"`

	// AuthProviderGroups is the set of auth provider groups that the identity is a member of.
	AuthProviderGroups []Group `json:"groups" gorm:"-"`
}

func (Identity) GetAuthProviderGroupIDs added in v0.9.0

func (i Identity) GetAuthProviderGroupIDs() []string

type Image added in v0.7.0

type Image struct {
	ID        string    `json:"id" gorm:"primaryKey;autoIncrement:false"`
	CreatedAt time.Time `json:"createdAt"`
	Data      []byte    `json:"-" gorm:"type:bytea;not null"`
	MIMEType  string    `json:"mimeType" gorm:"type:varchar(100);not null"`
}

func (*Image) BeforeCreate added in v0.7.0

func (i *Image) BeforeCreate(_ *gorm.DB) error

BeforeCreate will set the ID to a UUID v4.

type LLMProxyActivity

type LLMProxyActivity struct {
	ID             uint
	UserID         string
	CreatedAt      time.Time
	WorkflowID     string
	WorkflowStepID string
	AgentID        string
	ProjectID      string
	ThreadID       string
	RunID          string
	Path           string
}

type MCPAuditLog added in v0.8.0

type MCPAuditLog struct {
	ID                        uint                                  `json:"id" gorm:"primaryKey"`
	CreatedAt                 time.Time                             `json:"createdAt" gorm:"index"`
	UserID                    string                                `json:"userID" gorm:"index"`
	MCPID                     string                                `json:"mcpID" gorm:"index"`
	MCPServerDisplayName      string                                `json:"mcpServerDisplayName" gorm:"index"`
	MCPServerCatalogEntryName string                                `json:"mcpServerCatalogEntryName" gorm:"index"`
	ClientName                string                                `json:"clientName" gorm:"index"`
	ClientVersion             string                                `json:"clientVersion" gorm:"index"`
	ClientIP                  string                                `json:"clientIP" gorm:"index"`
	CallType                  string                                `json:"callType" gorm:"index"`
	CallIdentifier            string                                `json:"callIdentifier,omitempty" gorm:"index"`
	RequestBody               json.RawMessage                       `json:"requestBody,omitempty"`
	ResponseBody              json.RawMessage                       `json:"responseBody,omitempty"`
	ResponseStatus            int                                   `json:"responseStatus" gorm:"index"`
	Error                     string                                `json:"error,omitempty"`
	ProcessingTimeMs          int64                                 `json:"processingTimeMs" gorm:"index"`
	SessionID                 string                                `json:"sessionID,omitempty" gorm:"index"`
	WebhookStatuses           datatypes.JSONSlice[MCPWebhookStatus] `json:"webhookStatuses,omitempty"`

	// Additional metadata
	RequestID       string          `json:"requestID,omitempty" gorm:"index"`
	UserAgent       string          `json:"userAgent,omitempty"`
	RequestHeaders  json.RawMessage `json:"requestHeaders,omitempty"`
	ResponseHeaders json.RawMessage `json:"responseHeaders,omitempty"`
}

MCPAuditLog represents an audit log entry for MCP API calls

type MCPOAuthToken added in v0.8.0

type MCPOAuthToken struct {
	oauth2.Endpoint
	ClientID     string
	ClientSecret string
	RedirectURL  string
	Scopes       string

	State       string
	HashedState *string `gorm:"unique"`
	Verifier    string

	MCPID              string `gorm:"primaryKey"`
	UserID             string `gorm:"primaryKey"`
	OAuthAuthRequestID string `gorm:"index"`
	AccessToken        string
	TokenType          string
	RefreshToken       string
	Expiry             time.Time
	ExpiresIn          int64

	Encrypted bool
}

type MCPPromptReadStats added in v0.8.0

type MCPPromptReadStats struct {
	PromptName string `json:"promptName"`
	ReadCount  int64  `json:"readCount"`
}

MCPPromptReadStats represents statistics for individual prompt reads

type MCPResourceReadStats added in v0.8.0

type MCPResourceReadStats struct {
	ResourceURI string `json:"resourceUri"`
	ReadCount   int64  `json:"readCount"`
}

MCPResourceReadStats represents statistics for individual resource reads

type MCPToolCallStats added in v0.8.0

type MCPToolCallStats struct {
	ToolName  string                 `json:"-"`
	CallCount int64                  `json:"callCount"`
	Items     []MCPToolCallStatsItem `json:"items"`
}

MCPToolCallStats represents statistics for individual tool calls

type MCPToolCallStatsItem added in v0.8.0

type MCPToolCallStatsItem struct {
	ToolName         string    `json:"toolName"`
	CreatedAt        time.Time `json:"createdAt"`
	UserID           string    `json:"userID"`
	ProcessingTimeMs int64     `json:"processingTimeMs"`
	ResponseStatus   int       `json:"responseStatus"`
	Error            string    `json:"error"`
}

type MCPUsageStatItem added in v0.8.0

type MCPUsageStatItem struct {
	MCPID                     string                 `json:"mcpID"`
	MCPServerDisplayName      string                 `json:"mcpServerDisplayName"`
	MCPServerCatalogEntryName string                 `json:"mcpServerCatalogEntryName"`
	ToolCalls                 []MCPToolCallStats     `json:"toolCalls,omitempty"`
	ResourceReads             []MCPResourceReadStats `json:"resourceReads,omitempty"`
	PromptReads               []MCPPromptReadStats   `json:"promptReads,omitempty"`
}

MCPUsageStatItem represents usage statistics for MCP servers

type MCPUsageStatsList added in v0.8.0

type MCPUsageStatsList struct {
	TotalCalls  int64              `json:"totalCalls"`
	UniqueUsers int64              `json:"uniqueUsers"`
	TimeStart   time.Time          `json:"timeStart"`
	TimeEnd     time.Time          `json:"timeEnd"`
	Items       []MCPUsageStatItem `json:"items"`
}

type MCPWebhookStatus added in v0.8.0

type MCPWebhookStatus struct {
	Type    string `json:"type,omitempty"`
	URL     string `json:"url"`
	Status  string `json:"status"`
	Message string `json:"message,omitempty"`
}

type OAuthAppTypeConfig

type OAuthAppTypeConfig struct {
	DisplayName string            `json:"displayName"`
	Parameters  map[string]string `json:"parameters"`
}

type OAuthTokenRequestChallenge

type OAuthTokenRequestChallenge struct {
	State     string    `json:"state" gorm:"primaryKey"`
	Challenge string    `json:"challenge"`
	CreatedAt time.Time `json:"createdAt"`
}

type OAuthTokenResponse

type OAuthTokenResponse struct {
	State        string `json:"state"`
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
	ExpiresIn    int    `json:"expires_in"`
	ExtExpiresIn int    `json:"ext_expires_in"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	Ok           bool   `json:"ok"`
	Error        string `json:"error"`
	CreatedAt    time.Time
	Extras       map[string]string `json:"extras" gorm:"serializer:json"`
	Data         map[string]string `json:"data" gorm:"serializer:json"`
}

OAuthTokenResponse represents a response from the /token endpoint on an OAuth server. These do not get stored in the database.

type RemainingTokenUsage added in v0.8.0

type RemainingTokenUsage struct {
	PromptTokens              int
	CompletionTokens          int
	UnlimitedPromptTokens     bool
	UnlimitedCompletionTokens bool
}

type RunState added in v0.7.0

type RunState struct {
	UserID     string    `json:"userID"`
	Name       string    `json:"name" gorm:"primaryKey"`
	Namespace  string    `json:"namespace" gorm:"primaryKey"`
	CreatedAt  time.Time `json:"createdAt"`
	UpdatedAt  time.Time `json:"updatedAt"`
	ThreadName string    `json:"threadName,omitempty"`
	Program    []byte    `json:"program,omitempty"`
	ChatState  []byte    `json:"chatState,omitempty"`
	CallFrame  []byte    `json:"callFrame,omitempty"`
	Output     []byte    `json:"output,omitempty"`
	Done       bool      `json:"done,omitempty"`
	Error      string    `json:"error,omitempty"`
}

type RunTokenActivity added in v0.8.0

type RunTokenActivity struct {
	ID               uint
	CreatedAt        time.Time
	Name             string
	UserID           string
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
	PersonalToken    bool
}

type SalesforceOAuthTokenResponse added in v0.5.0

type SalesforceOAuthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	Signature    string `json:"signature"`
	Scope        string `json:"scope"`
	IDToken      string `json:"id_token"`
	InstanceURL  string `json:"instance_url"`
	ID           string `json:"id"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
	IssuedAt     string `json:"issued_at"`
}

type SessionCookie added in v0.10.0

type SessionCookie struct {
	HashedSessionID       string `json:"-" gorm:"primaryKey"`
	AuthProviderNamespace string `json:"-" gorm:"primaryKey"`
	AuthProviderName      string `json:"-" gorm:"primaryKey"`
	UserID                uint   `json:"-" gorm:"index"`
	Cookie                string
	Encrypted             bool
}

type SlackOAuthTokenResponse

type SlackOAuthTokenResponse struct {
	Ok    bool   `json:"ok"`
	Error string `json:"error"`
	AppID string `json:"app_id"`
	Team  struct {
		Name string `json:"name"`
		ID   string `json:"id"`
	} `json:"team"`
	AuthedUser struct {
		ID          string `json:"id"`
		Scope       string `json:"scope"`
		AccessToken string `json:"access_token"`
	} `json:"authed_user"`
	AccessToken string `json:"access_token"`
	Scope       string `json:"scope"`
}

type TokenRequest

type TokenRequest struct {
	ID                    string `gorm:"primaryKey"`
	CreatedAt             time.Time
	UpdatedAt             time.Time
	State                 string `gorm:"index"`
	Nonce                 string
	Token                 string
	ExpiresAt             time.Time
	CompletionRedirectURL string
	Error                 string
	TokenRetrieved        bool
}

type User

type User struct {
	ID             uint        `json:"id" gorm:"primaryKey"`
	CreatedAt      time.Time   `json:"createdAt"`
	DisplayName    string      `json:"displayName"`
	Username       string      `json:"username"`
	HashedUsername string      `json:"-" gorm:"unique"`
	Email          string      `json:"email"`
	HashedEmail    string      `json:"-"`
	VerifiedEmail  *bool       `json:"verifiedEmail,omitempty"`
	Role           types2.Role `json:"role"`
	IconURL        string      `json:"iconURL"`
	Timezone       string      `json:"timezone"`
	// LastActiveDay is the time of the last request made by this user, currently at the 24 hour granularity.
	LastActiveDay              time.Time `json:"lastActiveDay"`
	Internal                   bool      `json:"internal" gorm:"default:false"`
	DailyPromptTokensLimit     int       `json:"dailyPromptTokensLimit"`
	DailyCompletionTokensLimit int       `json:"dailyCompletionTokensLimit"`
	Encrypted                  bool      `json:"encrypted"`
	// Soft delete fields
	DeletedAt        *time.Time `json:"deletedAt,omitempty"`
	OriginalEmail    string     `json:"-"`
	OriginalUsername string     `json:"-"`
}

type UserQuery

type UserQuery struct {
	Username       string
	Email          string
	Role           types2.Role
	IncludeDeleted bool
}

func NewUserQuery

func NewUserQuery(u url.Values) UserQuery

func (UserQuery) Scope

func (q UserQuery) Scope(db *gorm.DB) *gorm.DB

Jump to

Keyboard shortcuts

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