models

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppInstallationStatePending = "pending"
	AppInstallationStateReady   = "ready"
	AppInstallationStateError   = "error"
)
View Source
const (
	AppInstallationRequestTypeSync = "sync"

	AppInstallationRequestStatePending   = "pending"
	AppInstallationRequestStateCompleted = "completed"
)
View Source
const (
	ProviderGitHub = "github"
	ProviderGoogle = "google"

	DomainTypeOrganization = "org"

	DisplayNameOwner  = "Owner"
	DisplayNameAdmin  = "Admin"
	DisplayNameViewer = "Viewer"

	RoleOrgOwner  = "org_owner"
	RoleOrgAdmin  = "org_admin"
	RoleOrgViewer = "org_viewer"

	// Role descriptions
	DescOrgOwner  = "Complete control over the organization including settings and deletion"
	DescOrgAdmin  = "Full management access to organization resources including canvases and users"
	DescOrgViewer = "Read-only access to organization resources"

	// Metadata descriptions
	MetaDescOrgOwner  = "Full control over organization settings, billing, and member management."
	MetaDescOrgAdmin  = "Can manage canvases, users, groups, and roles within the organization."
	MetaDescOrgViewer = "Read-only access to organization resources and information."
)
View Source
const (
	IntegrationTypeSemaphore = "semaphore"
	IntegrationTypeGithub    = "github"

	IntegrationAuthTypeToken = "token"
	IntegrationAuthTypeOIDC  = "oidc"
)
View Source
const (
	InvitationStatePending  = "pending"
	InvitationStateAccepted = "accepted"
)
View Source
const (
	WebhookStatePending = "pending"
	WebhookStateReady   = "ready"
	WebhookStateFailed  = "failed"
)
View Source
const (
	WorkflowEventStatePending = "pending"
	WorkflowEventStateRouted  = "routed"
)
View Source
const (
	WorkflowNodeStateReady      = "ready"
	WorkflowNodeStateProcessing = "processing"
	WorkflowNodeStateError      = "error"

	NodeTypeTrigger   = "trigger"
	NodeTypeComponent = "component"
	NodeTypeBlueprint = "blueprint"
	NodeTypeWidget    = "widget"
)
View Source
const (
	WorkflowNodeExecutionStatePending  = "pending"
	WorkflowNodeExecutionStateStarted  = "started"
	WorkflowNodeExecutionStateFinished = "finished"

	WorkflowNodeExecutionResultPassed    = "passed"
	WorkflowNodeExecutionResultFailed    = "failed"
	WorkflowNodeExecutionResultCancelled = "cancelled"

	WorkflowNodeExecutionResultReasonOk    = "ok"
	WorkflowNodeExecutionResultReasonError = "error"
)
View Source
const (
	NodeRequestTypeInvokeAction = "invoke-action"

	NodeExecutionRequestStatePending   = "pending"
	NodeExecutionRequestStateCompleted = "completed"
)

Variables

View Source
var (
	ErrNameAlreadyUsed         = fmt.Errorf("name already used")
	ErrInvitationAlreadyExists = fmt.Errorf("invitation already exists")
)

Functions

func CountActiveUsersByOrganizationIDs added in v0.0.18

func CountActiveUsersByOrganizationIDs(orgIDs []string) (map[string]int64, error)

func CountNodeExecutions

func CountNodeExecutions(workflowID uuid.UUID, nodeID string, states []string, results []string) (int64, error)

func CountNodeQueueItems

func CountNodeQueueItems(workflowID uuid.UUID, nodeID string) (int64, error)

func CountRootWorkflowEvents

func CountRootWorkflowEvents(workflowID uuid.UUID) (int64, error)

func CountWorkflowEvents

func CountWorkflowEvents(workflowID uuid.UUID, nodeID string) (int64, error)

func CountWorkflowsByOrganizationIDs added in v0.0.18

func CountWorkflowsByOrganizationIDs(orgIDs []string) (map[string]int64, error)

func CreateWorkflowNodeExecutionKVInTransaction

func CreateWorkflowNodeExecutionKVInTransaction(tx *gorm.DB, workflowID uuid.UUID, nodeID string, executionID uuid.UUID, key, value string) error

func DeleteGroupMetadata

func DeleteGroupMetadata(groupName, domainType, domainID string) error

func DeleteGroupMetadataInTransaction

func DeleteGroupMetadataInTransaction(tx *gorm.DB, groupName, domainType, domainID string) error

func DeleteMetadataForOrganization

func DeleteMetadataForOrganization(tx *gorm.DB, domainType, domainID string) error

func DeleteRoleMetadata

func DeleteRoleMetadata(roleName, domainType, domainID string) error

func DeleteRoleMetadataInTransaction

func DeleteRoleMetadataInTransaction(tx *gorm.DB, roleName, domainType, domainID string) error

func DeleteWorkflowNode

func DeleteWorkflowNode(tx *gorm.DB, node WorkflowNode) error

func FindRoleMetadataByNames

func FindRoleMetadataByNames(roleNames []string, domainType, domainID string) (map[string]*RoleMetadata, error)

func FormatDomain

func FormatDomain(domainType, domainID string) string

func GetActiveOrganizationIDs

func GetActiveOrganizationIDs() ([]string, error)

func HardDeleteOrganization

func HardDeleteOrganization(id string) error

func PrefixGroup

func PrefixGroup(groupName string) string

func PrefixRole

func PrefixRole(role string) string

func PrefixUser

func PrefixUser(userID string) string

func SaveInvitation

func SaveInvitation(invitation *OrganizationInvitation) error

func SoftDeleteOrganization

func SoftDeleteOrganization(id string) error

func SoftDeleteOrganizationInTransaction

func SoftDeleteOrganizationInTransaction(tx *gorm.DB, id string) error

func UpsertGroupMetadata

func UpsertGroupMetadata(groupName, domainType, domainID, displayName, description string) error

func UpsertGroupMetadataInTransaction

func UpsertGroupMetadataInTransaction(tx *gorm.DB, groupName, domainType, domainID, displayName, description string) error

func UpsertRoleMetadata

func UpsertRoleMetadata(roleName, domainType, domainID, displayName, description string) error

func UpsertRoleMetadataInTransaction

func UpsertRoleMetadataInTransaction(tx *gorm.DB, roleName, domainType, domainID, displayName, description string) error

func ValidateDomainType

func ValidateDomainType(domainType string) error

Types

type Account

type Account struct {
	ID    uuid.UUID `gorm:"primary_key;default:uuid_generate_v4()"`
	Email string
	Name  string
}

func CreateAccount

func CreateAccount(name, email string) (*Account, error)

func CreateAccountInTransaction

func CreateAccountInTransaction(tx *gorm.DB, name, email string) (*Account, error)

func FindAccountByEmail

func FindAccountByEmail(email string) (*Account, error)

func FindAccountByID

func FindAccountByID(id string) (*Account, error)

func FindAccountByProvider

func FindAccountByProvider(provider, providerID string) (*Account, error)

func (*Account) FindAccountProviderByID

func (a *Account) FindAccountProviderByID(provider, providerID string) (*AccountProvider, error)

func (*Account) FindPendingInvitations

func (a *Account) FindPendingInvitations() ([]OrganizationInvitation, error)

func (*Account) GetAccountProvider

func (a *Account) GetAccountProvider(provider string) (*AccountProvider, error)

func (*Account) GetAccountProviders

func (a *Account) GetAccountProviders() ([]AccountProvider, error)

func (*Account) UpdateEmail

func (a *Account) UpdateEmail(newEmail string) error

func (*Account) UpdateEmailForProvider

func (a *Account) UpdateEmailForProvider(newEmail, provider, providerID string) error

type AccountPasswordAuth added in v0.0.18

type AccountPasswordAuth struct {
	ID           uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
	AccountID    uuid.UUID
	PasswordHash string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func CreateAccountPasswordAuth added in v0.0.18

func CreateAccountPasswordAuth(accountID uuid.UUID, passwordHash string) (*AccountPasswordAuth, error)

func CreateAccountPasswordAuthInTransaction added in v0.0.18

func CreateAccountPasswordAuthInTransaction(tx *gorm.DB, accountID uuid.UUID, passwordHash string) (*AccountPasswordAuth, error)

func FindAccountPasswordAuthByAccountID added in v0.0.18

func FindAccountPasswordAuthByAccountID(accountID uuid.UUID) (*AccountPasswordAuth, error)

func FindAccountPasswordAuthByAccountIDInTransaction added in v0.0.18

func FindAccountPasswordAuthByAccountIDInTransaction(tx *gorm.DB, accountID uuid.UUID) (*AccountPasswordAuth, error)

func (AccountPasswordAuth) TableName added in v0.0.18

func (AccountPasswordAuth) TableName() string

func (*AccountPasswordAuth) UpdatePasswordHash added in v0.0.18

func (a *AccountPasswordAuth) UpdatePasswordHash(passwordHash string) error

func (*AccountPasswordAuth) UpdatePasswordHashInTransaction added in v0.0.18

func (a *AccountPasswordAuth) UpdatePasswordHashInTransaction(tx *gorm.DB, passwordHash string) error

type AccountProvider

type AccountProvider struct {
	ID             uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
	AccountID      uuid.UUID
	Provider       string
	ProviderID     string
	Username       string
	Email          string
	Name           string
	AvatarURL      string
	AccessToken    string
	RefreshToken   string
	TokenExpiresAt *time.Time
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

type AppInstallation

type AppInstallation struct {
	ID               uuid.UUID `gorm:"primary_key;default:uuid_generate_v4()"`
	OrganizationID   uuid.UUID
	AppName          string
	InstallationName string
	State            string
	StateDescription string
	Configuration    datatypes.JSONType[map[string]any]
	Metadata         datatypes.JSONType[map[string]any]
	BrowserAction    *datatypes.JSONType[BrowserAction]
	CreatedAt        *time.Time
	UpdatedAt        *time.Time
	DeletedAt        gorm.DeletedAt `gorm:"index"`
}

func CreateAppInstallation

func CreateAppInstallation(id, orgID uuid.UUID, appName string, installationName string, config map[string]any) (*AppInstallation, error)

func FindAppInstallation

func FindAppInstallation(orgID, installationID uuid.UUID) (*AppInstallation, error)

func FindAppInstallationByName

func FindAppInstallationByName(orgID uuid.UUID, installationName string) (*AppInstallation, error)

func FindMaybeDeletedInstallationInTransaction

func FindMaybeDeletedInstallationInTransaction(tx *gorm.DB, installationID uuid.UUID) (*AppInstallation, error)

func FindUnscopedAppInstallation

func FindUnscopedAppInstallation(installationID uuid.UUID) (*AppInstallation, error)

func FindUnscopedAppInstallationInTransaction

func FindUnscopedAppInstallationInTransaction(tx *gorm.DB, installationID uuid.UUID) (*AppInstallation, error)

func ListAppInstallations

func ListAppInstallations(orgID uuid.UUID) ([]AppInstallation, error)

func ListDeletedAppInstallations

func ListDeletedAppInstallations() ([]AppInstallation, error)

func LockAppInstallation

func LockAppInstallation(tx *gorm.DB, ID uuid.UUID) (*AppInstallation, error)

func (*AppInstallation) CreateSyncRequest added in v0.0.21

func (a *AppInstallation) CreateSyncRequest(tx *gorm.DB, runAt *time.Time) error

func (*AppInstallation) GetRequest added in v0.0.21

func (a *AppInstallation) GetRequest(ID string) (*AppInstallationRequest, error)

func (*AppInstallation) ListRequests added in v0.0.21

func (a *AppInstallation) ListRequests(reqType string) ([]AppInstallationRequest, error)

func (*AppInstallation) SoftDelete

func (a *AppInstallation) SoftDelete() error

func (*AppInstallation) SoftDeleteInTransaction

func (a *AppInstallation) SoftDeleteInTransaction(tx *gorm.DB) error

type AppInstallationRequest added in v0.0.21

type AppInstallationRequest struct {
	ID                uuid.UUID
	AppInstallationID uuid.UUID
	State             string
	Type              string
	RunAt             time.Time
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

func FindPendingRequestForAppInstallation added in v0.0.21

func FindPendingRequestForAppInstallation(tx *gorm.DB, installationID uuid.UUID) (*AppInstallationRequest, error)

func ListAppInstallationRequests added in v0.0.21

func ListAppInstallationRequests() ([]AppInstallationRequest, error)

func LockAppInstallationRequest added in v0.0.21

func LockAppInstallationRequest(tx *gorm.DB, id uuid.UUID) (*AppInstallationRequest, error)

func (*AppInstallationRequest) Complete added in v0.0.21

func (r *AppInstallationRequest) Complete(tx *gorm.DB) error

type AppInstallationSecret

type AppInstallationSecret struct {
	ID             uuid.UUID `gorm:"primary_key;default:uuid_generate_v4()"`
	OrganizationID uuid.UUID
	InstallationID uuid.UUID
	Name           string
	Value          []byte
	CreatedAt      *time.Time
	UpdatedAt      *time.Time
}

type Blueprint

type Blueprint struct {
	ID             uuid.UUID
	OrganizationID uuid.UUID
	Name           string
	Description    string
	Icon           string
	Color          string
	CreatedBy      *uuid.UUID
	CreatedAt      *time.Time
	UpdatedAt      *time.Time
	Nodes          datatypes.JSONSlice[Node]
	Edges          datatypes.JSONSlice[Edge]
	Configuration  datatypes.JSONSlice[configuration.Field]
	OutputChannels datatypes.JSONSlice[BlueprintOutputChannel]
}

func FindBlueprint

func FindBlueprint(orgID, id string) (*Blueprint, error)

func FindBlueprintByName

func FindBlueprintByName(name string, orgID uuid.UUID) (*Blueprint, error)

func FindUnscopedBlueprint

func FindUnscopedBlueprint(id string) (*Blueprint, error)

func FindUnscopedBlueprintInTransaction

func FindUnscopedBlueprintInTransaction(tx *gorm.DB, id string) (*Blueprint, error)

func (*Blueprint) FindEdges

func (b *Blueprint) FindEdges(sourceID string, channel string) []Edge

func (*Blueprint) FindNode

func (b *Blueprint) FindNode(id string) (*Node, error)

func (*Blueprint) FindRootNode

func (b *Blueprint) FindRootNode() *Node

type BlueprintOutputChannel

type BlueprintOutputChannel struct {
	Name              string `json:"name"`
	NodeID            string `json:"node_id"`
	NodeOutputChannel string `json:"node_output_channel"`
}

type BlueprintRef

type BlueprintRef struct {
	ID string `json:"id"`
}

type BrowserAction

type BrowserAction struct {
	URL         string
	Method      string
	FormFields  map[string]string
	Description string
}

type ComponentRef

type ComponentRef struct {
	Name string `json:"name"`
}

type Edge

type Edge struct {
	SourceID string `json:"source_id"`
	TargetID string `json:"target_id"`
	Channel  string `json:"channel"`
}

type GroupMetadata

type GroupMetadata struct {
	ID          uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
	GroupName   string    `json:"group_name" gorm:"not null;index"`
	DomainType  string    `json:"domain_type" gorm:"not null;index"`
	DomainID    string    `json:"domain_id" gorm:"not null;index"`
	DisplayName string    `json:"display_name" gorm:"not null"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

func FindGroupMetadata

func FindGroupMetadata(groupName, domainType, domainID string) (*GroupMetadata, error)

func (*GroupMetadata) BeforeCreate

func (gm *GroupMetadata) BeforeCreate(tx *gorm.DB) error

func (*GroupMetadata) Create

func (gm *GroupMetadata) Create() error

func (*GroupMetadata) CreateInTransaction

func (gm *GroupMetadata) CreateInTransaction(tx *gorm.DB) error

func (*GroupMetadata) Update

func (gm *GroupMetadata) Update() error

func (*GroupMetadata) UpdateInTransaction

func (gm *GroupMetadata) UpdateInTransaction(tx *gorm.DB) error

type Integration

type Integration struct {
	ID         uuid.UUID `gorm:"primary_key;default:uuid_generate_v4()"`
	Name       string
	DomainType string
	DomainID   uuid.UUID
	Type       string
	URL        string
	AuthType   string
	Auth       datatypes.JSONType[IntegrationAuth]
	CreatedAt  *time.Time
	CreatedBy  uuid.UUID
	UpdatedAt  *time.Time
}

func CreateIntegration

func CreateIntegration(integration *Integration) (*Integration, error)

func FindDomainIntegration

func FindDomainIntegration(domainType string, domainID uuid.UUID, id uuid.UUID) (*Integration, error)

func FindIntegrationByIDInTransaction

func FindIntegrationByIDInTransaction(tx *gorm.DB, id uuid.UUID) (*Integration, error)

func FindIntegrationByName

func FindIntegrationByName(domainType string, domainID uuid.UUID, name string) (*Integration, error)

func ListIntegrations

func ListIntegrations(domainType string, domainID uuid.UUID) ([]*Integration, error)

func (*Integration) Update

func (i *Integration) Update() error

type IntegrationAuth

type IntegrationAuth struct {
	Token *IntegrationAuthToken `json:"token"`
}

type IntegrationAuthToken

type IntegrationAuthToken struct {
	ValueFrom ValueDefinitionFrom `json:"value_from"`
}

type IntegrationResource

type IntegrationResource struct {
	Name            string
	Type            string
	IntegrationName string
	DomainType      string
}

type InvokeAction

type InvokeAction struct {
	ActionName string         `json:"action_name"`
	Parameters map[string]any `json:"parameters"`
}

type Node

type Node struct {
	ID                string         `json:"id"`
	Name              string         `json:"name"`
	Type              string         `json:"type"`
	Ref               NodeRef        `json:"ref"`
	Configuration     map[string]any `json:"configuration"`
	Metadata          map[string]any `json:"metadata"`
	Position          Position       `json:"position"`
	IsCollapsed       bool           `json:"isCollapsed"`
	AppInstallationID *string        `json:"appInstallationId,omitempty"`
	ErrorMessage      *string        `json:"errorMessage,omitempty"`
}

type NodeExecutionRequestSpec

type NodeExecutionRequestSpec struct {
	InvokeAction *InvokeAction `json:"invoke_action,omitempty"`
}

type NodeRef

type NodeRef struct {
	Component *ComponentRef `json:"component,omitempty"`
	Blueprint *BlueprintRef `json:"blueprint,omitempty"`
	Trigger   *TriggerRef   `json:"trigger,omitempty"`
	Widget    *WidgetRef    `json:"widget,omitempty"`
}

type Organization

type Organization struct {
	ID               uuid.UUID `gorm:"primary_key;default:uuid_generate_v4()"`
	Name             string    `gorm:"uniqueIndex"`
	Description      string
	AllowedProviders datatypes.JSONSlice[string]
	CreatedAt        *time.Time
	UpdatedAt        *time.Time
	DeletedAt        gorm.DeletedAt `gorm:"index"`
}

func CreateOrganization

func CreateOrganization(name, description string) (*Organization, error)

func CreateOrganizationInTransaction

func CreateOrganizationInTransaction(tx *gorm.DB, name, description string) (*Organization, error)

func FindOrganizationByID

func FindOrganizationByID(id string) (*Organization, error)

func FindOrganizationByName

func FindOrganizationByName(name string) (*Organization, error)

func FindOrganizationsForAccount

func FindOrganizationsForAccount(email string) ([]Organization, error)

func ListOrganizationsByIDs

func ListOrganizationsByIDs(ids []string) ([]Organization, error)

func (*Organization) IsProviderAllowed

func (o *Organization) IsProviderAllowed(provider string) bool

type OrganizationInvitation

type OrganizationInvitation struct {
	ID             uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
	OrganizationID uuid.UUID
	Email          string
	InvitedBy      uuid.UUID
	State          string
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

func CreateInvitation

func CreateInvitation(organizationID, invitedBy uuid.UUID, email, state string) (*OrganizationInvitation, error)

func CreateInvitationInTransaction

func CreateInvitationInTransaction(tx *gorm.DB, organizationID, invitedBy uuid.UUID, email, state string) (*OrganizationInvitation, error)

func FindInvitationByID

func FindInvitationByID(invitationID string) (*OrganizationInvitation, error)

func FindInvitationByIDWithState

func FindInvitationByIDWithState(invitationID string, state string) (*OrganizationInvitation, error)

func FindPendingInvitation

func FindPendingInvitation(email, organizationID string) (*OrganizationInvitation, error)

func FindPendingInvitationInTransaction

func FindPendingInvitationInTransaction(tx *gorm.DB, email, organizationID string) (*OrganizationInvitation, error)

func ListInvitationsInState

func ListInvitationsInState(organizationID string, state string) ([]OrganizationInvitation, error)

func (*OrganizationInvitation) Delete

func (i *OrganizationInvitation) Delete() error

type Position

type Position struct {
	X int `json:"x"`
	Y int `json:"y"`
}

type RoleMetadata

type RoleMetadata struct {
	ID          uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
	RoleName    string    `json:"role_name" gorm:"not null;index"`
	DomainType  string    `json:"domain_type" gorm:"not null;index"`
	DomainID    string    `json:"domain_id" gorm:"not null;index"`
	DisplayName string    `json:"display_name" gorm:"not null"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

func FindRoleMetadata

func FindRoleMetadata(roleName, domainType, domainID string) (*RoleMetadata, error)

func (*RoleMetadata) BeforeCreate

func (rm *RoleMetadata) BeforeCreate(tx *gorm.DB) error

func (*RoleMetadata) Create

func (rm *RoleMetadata) Create() error

func (*RoleMetadata) CreateInTransaction

func (rm *RoleMetadata) CreateInTransaction(tx *gorm.DB) error

func (*RoleMetadata) Update

func (rm *RoleMetadata) Update() error

func (*RoleMetadata) UpdateInTransaction

func (rm *RoleMetadata) UpdateInTransaction(tx *gorm.DB) error

type Secret

type Secret struct {
	ID         uuid.UUID `gorm:"primary_key;default:uuid_generate_v4()"`
	DomainType string
	DomainID   uuid.UUID
	Name       string
	CreatedAt  *time.Time
	CreatedBy  uuid.UUID
	UpdatedAt  *time.Time
	Provider   string
	Data       []byte
}

func CreateSecret

func CreateSecret(name, provider, requesterID, domainType string, domainID uuid.UUID, data []byte) (*Secret, error)

func FindSecretByID

func FindSecretByID(domainType string, domainID uuid.UUID, id string) (*Secret, error)

func FindSecretByName

func FindSecretByName(domainType string, domainID uuid.UUID, name string) (*Secret, error)

func FindSecretByNameInTransaction

func FindSecretByNameInTransaction(tx *gorm.DB, domainType string, domainID uuid.UUID, name string) (*Secret, error)

func ListSecrets

func ListSecrets(domainType string, domainID uuid.UUID) ([]Secret, error)

func (*Secret) Delete

func (s *Secret) Delete() error

func (*Secret) UpdateData

func (s *Secret) UpdateData(data []byte) (*Secret, error)

type SecretData

type SecretData struct {
	Local map[string]string `json:"local"`
}

type TriggerRef

type TriggerRef struct {
	Name string `json:"name"`
}

type User

type User struct {
	ID             uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
	OrganizationID uuid.UUID
	AccountID      uuid.UUID
	Email          string
	Name           string
	TokenHash      string
	CreatedAt      time.Time
	UpdatedAt      time.Time
	DeletedAt      gorm.DeletedAt
}

func CreateUser

func CreateUser(orgID, accountID uuid.UUID, email, name string) (*User, error)

func CreateUserInTransaction

func CreateUserInTransaction(tx *gorm.DB, orgID, accountID uuid.UUID, email, name string) (*User, error)

func FindActiveUserByEmail

func FindActiveUserByEmail(orgID, email string) (*User, error)

func FindActiveUserByID

func FindActiveUserByID(orgID, id string) (*User, error)

func FindActiveUserByIDInTransaction

func FindActiveUserByIDInTransaction(tx *gorm.DB, orgID, id string) (*User, error)

func FindActiveUserByTokenHash

func FindActiveUserByTokenHash(tokenHash string) (*User, error)

func FindAnyUserByEmail

func FindAnyUserByEmail(email string) (*User, error)

func FindMaybeDeletedUserByEmail

func FindMaybeDeletedUserByEmail(orgID, email string) (*User, error)

func FindMaybeDeletedUserByID

func FindMaybeDeletedUserByID(orgID, id string) (*User, error)

NOTE: this method returns soft deleted users too. Make sure you really need to use it this one, and not FindActiveUserByID instead.

func FindUnscopedUserByID

func FindUnscopedUserByID(id string) (*User, error)

func (*User) Delete

func (u *User) Delete() error

func (*User) Restore

func (u *User) Restore() error

func (*User) RestoreInTransaction

func (u *User) RestoreInTransaction(tx *gorm.DB) error

func (*User) UpdateTokenHash

func (u *User) UpdateTokenHash(tokenHash string) error

type ValueDefinitionFrom

type ValueDefinitionFrom struct {
	Secret *ValueDefinitionFromSecret `json:"secret,omitempty"`
}

type ValueDefinitionFromSecret

type ValueDefinitionFromSecret struct {
	Name string `json:"name"`
	Key  string `json:"key"`
}

type Webhook

type Webhook struct {
	ID                uuid.UUID `gorm:"primary_key;default:uuid_generate_v4()"`
	State             string
	Secret            []byte
	Configuration     datatypes.JSONType[any]
	Metadata          datatypes.JSONType[any]
	IntegrationID     *uuid.UUID
	AppInstallationID *uuid.UUID
	Resource          datatypes.JSONType[WebhookResource]
	RetryCount        int `gorm:"default:0"`
	MaxRetries        int `gorm:"default:3"`
	CreatedAt         *time.Time
	UpdatedAt         *time.Time
	DeletedAt         gorm.DeletedAt `gorm:"index"`
}

func FindWebhook

func FindWebhook(id uuid.UUID) (*Webhook, error)

func FindWebhookInTransaction

func FindWebhookInTransaction(tx *gorm.DB, id uuid.UUID) (*Webhook, error)

func ListAppInstallationWebhooks

func ListAppInstallationWebhooks(tx *gorm.DB, installationID uuid.UUID) ([]Webhook, error)

func ListDeletedWebhooks

func ListDeletedWebhooks() ([]Webhook, error)

func ListPendingWebhooks

func ListPendingWebhooks() ([]Webhook, error)

func ListUnscopedAppInstallationWebhooks

func ListUnscopedAppInstallationWebhooks(tx *gorm.DB, installationID uuid.UUID) ([]Webhook, error)

func LockWebhook

func LockWebhook(tx *gorm.DB, ID uuid.UUID) (*Webhook, error)

func (*Webhook) HasExceededRetries

func (w *Webhook) HasExceededRetries() bool

func (*Webhook) IncrementRetry

func (w *Webhook) IncrementRetry(tx *gorm.DB) error

func (*Webhook) MarkFailed

func (w *Webhook) MarkFailed(tx *gorm.DB) error

func (*Webhook) Ready

func (w *Webhook) Ready(tx *gorm.DB) error

func (*Webhook) ReadyWithMetadata

func (w *Webhook) ReadyWithMetadata(tx *gorm.DB, metadata any) error

type WebhookResource

type WebhookResource struct {
	Type string `json:"type"`
	ID   string `json:"id"`
	Name string `json:"name"`
}

type WidgetRef added in v0.0.18

type WidgetRef struct {
	Name string `json:"name"`
}

type Workflow

type Workflow struct {
	ID             uuid.UUID
	OrganizationID uuid.UUID
	Name           string
	Description    string
	CreatedBy      *uuid.UUID
	CreatedAt      *time.Time
	UpdatedAt      *time.Time
	DeletedAt      gorm.DeletedAt `gorm:"index"`
	Nodes          datatypes.JSONSlice[Node]
	Edges          datatypes.JSONSlice[Edge]
}

func FindUnscopedWorkflow

func FindUnscopedWorkflow(id uuid.UUID) (*Workflow, error)

func FindUnscopedWorkflowInTransaction

func FindUnscopedWorkflowInTransaction(tx *gorm.DB, id uuid.UUID) (*Workflow, error)

func FindWorkflow

func FindWorkflow(orgID, id uuid.UUID) (*Workflow, error)

func FindWorkflowByName

func FindWorkflowByName(name string, organizationID uuid.UUID) (*Workflow, error)

func FindWorkflowInTransaction

func FindWorkflowInTransaction(tx *gorm.DB, orgID, id uuid.UUID) (*Workflow, error)

func FindWorkflowWithoutOrgScope

func FindWorkflowWithoutOrgScope(id uuid.UUID) (*Workflow, error)

func FindWorkflowWithoutOrgScopeInTransaction

func FindWorkflowWithoutOrgScopeInTransaction(tx *gorm.DB, id uuid.UUID) (*Workflow, error)

func ListDeletedWorkflows

func ListDeletedWorkflows() ([]Workflow, error)

func ListWorkflows

func ListWorkflows(orgID string) ([]Workflow, error)

func LockWorkflow

func LockWorkflow(tx *gorm.DB, id uuid.UUID) (*Workflow, error)

func (*Workflow) FindEdges

func (w *Workflow) FindEdges(sourceID string, channel string) []Edge

func (*Workflow) FindNode

func (w *Workflow) FindNode(id string) (*WorkflowNode, error)

func (*Workflow) SoftDelete

func (w *Workflow) SoftDelete() error

func (*Workflow) SoftDeleteInTransaction

func (w *Workflow) SoftDeleteInTransaction(tx *gorm.DB) error

type WorkflowEvent

type WorkflowEvent struct {
	ID          uuid.UUID `gorm:"primaryKey;default:uuid_generate_v4()"`
	WorkflowID  uuid.UUID
	NodeID      string
	Channel     string
	Data        datatypes.JSONType[any]
	ExecutionID *uuid.UUID
	State       string
	CreatedAt   *time.Time
}

func FindLastEventPerNode

func FindLastEventPerNode(workflowID uuid.UUID) ([]WorkflowEvent, error)

FindLastEventPerNode finds the most recent event for each node in a workflow using DISTINCT ON to get one event per node_id, ordered by created_at DESC Only returns events for nodes that have not been deleted

func FindWorkflowEvent

func FindWorkflowEvent(id uuid.UUID) (*WorkflowEvent, error)

func FindWorkflowEventForWorkflow

func FindWorkflowEventForWorkflow(workflowID uuid.UUID, id uuid.UUID) (*WorkflowEvent, error)

func FindWorkflowEventInTransaction

func FindWorkflowEventInTransaction(tx *gorm.DB, id uuid.UUID) (*WorkflowEvent, error)

func FindWorkflowEvents

func FindWorkflowEvents(ids []string) ([]WorkflowEvent, error)

func FindWorkflowEventsForExecutions

func FindWorkflowEventsForExecutions(executionIDs []string) ([]WorkflowEvent, error)

func ListPendingWorkflowEvents

func ListPendingWorkflowEvents() ([]WorkflowEvent, error)

func ListRootWorkflowEvents

func ListRootWorkflowEvents(workflowID uuid.UUID, limit int, before *time.Time) ([]WorkflowEvent, error)

func ListWorkflowEvents

func ListWorkflowEvents(workflowID uuid.UUID, nodeID string, limit int, before *time.Time) ([]WorkflowEvent, error)

func LockWorkflowEvent

func LockWorkflowEvent(tx *gorm.DB, id uuid.UUID) (*WorkflowEvent, error)

func (*WorkflowEvent) Routed

func (e *WorkflowEvent) Routed() error

func (*WorkflowEvent) RoutedInTransaction

func (e *WorkflowEvent) RoutedInTransaction(tx *gorm.DB) error

type WorkflowNode

type WorkflowNode struct {
	WorkflowID        uuid.UUID `gorm:"primaryKey"`
	NodeID            string    `gorm:"primaryKey"`
	ParentNodeID      *string
	Name              string
	State             string
	StateReason       *string
	Type              string
	Position          datatypes.JSONType[Position]
	Ref               datatypes.JSONType[NodeRef]
	Configuration     datatypes.JSONType[map[string]any]
	Metadata          datatypes.JSONType[map[string]any]
	IsCollapsed       bool
	WebhookID         *uuid.UUID
	AppInstallationID *uuid.UUID
	CreatedAt         *time.Time
	UpdatedAt         *time.Time
	DeletedAt         gorm.DeletedAt `gorm:"index"`
}

func FindWebhookNodes

func FindWebhookNodes(webhookID uuid.UUID) ([]WorkflowNode, error)

func FindWebhookNodesInTransaction

func FindWebhookNodesInTransaction(tx *gorm.DB, webhookID uuid.UUID) ([]WorkflowNode, error)

func FindWorkflowNode

func FindWorkflowNode(tx *gorm.DB, workflowID uuid.UUID, nodeID string) (*WorkflowNode, error)

func FindWorkflowNodes

func FindWorkflowNodes(workflowID uuid.UUID) ([]WorkflowNode, error)

func FindWorkflowNodesByIDs

func FindWorkflowNodesByIDs(tx *gorm.DB, workflowID uuid.UUID, nodeIDs []string) ([]WorkflowNode, error)

func FindWorkflowNodesInTransaction

func FindWorkflowNodesInTransaction(tx *gorm.DB, workflowID uuid.UUID) ([]WorkflowNode, error)

func ListReadyTriggers

func ListReadyTriggers() ([]WorkflowNode, error)

func ListWorkflowNodesReady

func ListWorkflowNodesReady() ([]WorkflowNode, error)

func LockWorkflowNode

func LockWorkflowNode(tx *gorm.DB, workflowID uuid.UUID, nodeId string) (*WorkflowNode, error)

func (*WorkflowNode) CreateRequest

func (w *WorkflowNode) CreateRequest(tx *gorm.DB, reqType string, spec NodeExecutionRequestSpec, runAt *time.Time) error

func (*WorkflowNode) FirstQueueItem

func (w *WorkflowNode) FirstQueueItem(tx *gorm.DB) (*WorkflowNodeQueueItem, error)

func (*WorkflowNode) UpdateState

func (w *WorkflowNode) UpdateState(tx *gorm.DB, state string) error

type WorkflowNodeExecution

type WorkflowNodeExecution struct {
	ID         uuid.UUID `gorm:"primaryKey;default:uuid_generate_v4()"`
	WorkflowID uuid.UUID
	NodeID     string
	CreatedAt  *time.Time
	UpdatedAt  *time.Time

	//
	// Reference to the root WorkflowEvent record that started
	// this whole execution chain.
	//
	// This gives us an easy way to find all the executions
	// for that event with a simple query.
	//
	RootEventID uuid.UUID

	//
	// Reference to the previous execution.
	// This is what allows us to build execution chains,
	// from any execution.
	//
	PreviousExecutionID *uuid.UUID

	//
	// Reference to the parent execution.
	// This is used for node executions inside of a blueprint node,
	// to reference the parent blueprint node execution.
	//
	ParentExecutionID *uuid.UUID

	//
	// The reference to a WorkflowEvent record,
	// which holds the input for this execution.
	//
	EventID uuid.UUID

	//
	// State management fields.
	//
	State         string
	Result        string
	ResultReason  string
	ResultMessage string

	//
	// Components can store metadata about each execution here.
	// This allows them to control the behavior of each execution.
	//
	Metadata datatypes.JSONType[map[string]any]

	//
	// The configuration is copied from the node.
	// This enables us to allow node configuration updates
	// while executions are running.
	// Only new executions will use the new node configuration.
	//
	Configuration datatypes.JSONType[map[string]any]
}

func CreatePendingChildExecution

func CreatePendingChildExecution(tx *gorm.DB, parent *WorkflowNodeExecution, childNodeID string, config map[string]any) (*WorkflowNodeExecution, error)

func FindChildExecutions

func FindChildExecutions(parentExecutionID uuid.UUID, states []string) ([]WorkflowNodeExecution, error)

func FindChildExecutionsForMultiple

func FindChildExecutionsForMultiple(parentExecutionIDs []string) ([]WorkflowNodeExecution, error)

func FindChildExecutionsInTransaction

func FindChildExecutionsInTransaction(tx *gorm.DB, parentExecutionID uuid.UUID, states []string) ([]WorkflowNodeExecution, error)

func FindLastExecutionPerNode

func FindLastExecutionPerNode(workflowID uuid.UUID) ([]WorkflowNodeExecution, error)

FindLastExecutionPerNode finds the most recent execution for each node in a workflow using DISTINCT ON to get one execution per node_id, ordered by created_at DESC Only returns executions for nodes that have not been deleted

func FindNodeExecution

func FindNodeExecution(workflowID, id uuid.UUID) (*WorkflowNodeExecution, error)

func FindNodeExecutionInTransaction

func FindNodeExecutionInTransaction(tx *gorm.DB, workflowID, id uuid.UUID) (*WorkflowNodeExecution, error)

func FindNodeExecutionWithNodeID

func FindNodeExecutionWithNodeID(workflowID, id uuid.UUID, nodeID string) (*WorkflowNodeExecution, error)

func FindNodeExecutionWithNodeIDInTransaction

func FindNodeExecutionWithNodeIDInTransaction(tx *gorm.DB, workflowID, id uuid.UUID, nodeID string) (*WorkflowNodeExecution, error)

func FirstNodeExecutionByKVInTransaction

func FirstNodeExecutionByKVInTransaction(tx *gorm.DB, workflowID uuid.UUID, nodeID, key, value string) (*WorkflowNodeExecution, error)

func ListNodeExecutions

func ListNodeExecutions(workflowID uuid.UUID, nodeID string, states []string, results []string, limit int, beforeTime *time.Time) ([]WorkflowNodeExecution, error)

func ListPendingNodeExecutions

func ListPendingNodeExecutions() ([]WorkflowNodeExecution, error)

func LockWorkflowNodeExecution

func LockWorkflowNodeExecution(tx *gorm.DB, id uuid.UUID) (*WorkflowNodeExecution, error)

func (*WorkflowNodeExecution) Cancel

func (e *WorkflowNodeExecution) Cancel() error

func (*WorkflowNodeExecution) CancelInTransaction

func (e *WorkflowNodeExecution) CancelInTransaction(tx *gorm.DB) error

func (*WorkflowNodeExecution) CreateRequest

func (e *WorkflowNodeExecution) CreateRequest(tx *gorm.DB, reqType string, spec NodeExecutionRequestSpec, runAt *time.Time) error

func (*WorkflowNodeExecution) Fail

func (e *WorkflowNodeExecution) Fail(reason, message string) error

func (*WorkflowNodeExecution) FailInTransaction

func (e *WorkflowNodeExecution) FailInTransaction(tx *gorm.DB, reason, message string) error

func (*WorkflowNodeExecution) GetInput

func (e *WorkflowNodeExecution) GetInput(tx *gorm.DB) (any, error)

func (*WorkflowNodeExecution) GetOutputs

func (e *WorkflowNodeExecution) GetOutputs() ([]WorkflowEvent, error)

func (*WorkflowNodeExecution) GetOutputsInTransaction

func (e *WorkflowNodeExecution) GetOutputsInTransaction(tx *gorm.DB) ([]WorkflowEvent, error)

func (*WorkflowNodeExecution) GetParentExecutionID

func (e *WorkflowNodeExecution) GetParentExecutionID() string

func (*WorkflowNodeExecution) GetPreviousExecutionID

func (e *WorkflowNodeExecution) GetPreviousExecutionID() string

func (*WorkflowNodeExecution) Pass

func (e *WorkflowNodeExecution) Pass(outputs map[string][]any) ([]WorkflowEvent, error)

func (*WorkflowNodeExecution) PassInTransaction

func (e *WorkflowNodeExecution) PassInTransaction(tx *gorm.DB, channelOutputs map[string][]any) ([]WorkflowEvent, error)

func (*WorkflowNodeExecution) Start

func (e *WorkflowNodeExecution) Start() error

func (*WorkflowNodeExecution) StartInTransaction

func (e *WorkflowNodeExecution) StartInTransaction(tx *gorm.DB) error

type WorkflowNodeExecutionKV

type WorkflowNodeExecutionKV struct {
	ID          uuid.UUID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()"`
	WorkflowID  uuid.UUID `gorm:"type:uuid;not null"`
	NodeID      string    `gorm:"type:varchar(128);not null"`
	ExecutionID uuid.UUID `gorm:"type:uuid;not null"`
	Key         string    `gorm:"type:text;not null"`
	Value       string    `gorm:"type:text;not null"`
	CreatedAt   *time.Time
}

type WorkflowNodeQueueItem

type WorkflowNodeQueueItem struct {
	ID         uuid.UUID `gorm:"primaryKey;default:uuid_generate_v4()"`
	WorkflowID uuid.UUID
	NodeID     string
	CreatedAt  *time.Time

	//
	// Reference to the root WorkflowEvent record that started
	// this whole execution chain.
	//
	// This gives us an easy way to find all the queue items
	// for that event with a simple query.
	//
	RootEventID uuid.UUID
	RootEvent   *WorkflowEvent `gorm:"foreignKey:RootEventID"`

	//
	// The reference to a WorkflowEvent record,
	// which holds the input for this queue item.
	//
	EventID uuid.UUID
}

func FindNextQueueItemPerNode

func FindNextQueueItemPerNode(workflowID uuid.UUID) ([]WorkflowNodeQueueItem, error)

FindNextQueueItemPerNode finds the next (oldest) queue item for each node in a workflow using DISTINCT ON to get one queue item per node_id, ordered by created_at ASC Only returns queue items for nodes that have not been deleted

func FindNodeQueueItem

func FindNodeQueueItem(workflowID uuid.UUID, queueItemID uuid.UUID) (*WorkflowNodeQueueItem, error)

func ListNodeQueueItems

func ListNodeQueueItems(workflowID uuid.UUID, nodeID string, limit int, beforeTime *time.Time) ([]WorkflowNodeQueueItem, error)

func (*WorkflowNodeQueueItem) Delete

func (i *WorkflowNodeQueueItem) Delete(tx *gorm.DB) error

type WorkflowNodeReference

type WorkflowNodeReference struct {
	WorkflowID   uuid.UUID
	WorkflowName string
	NodeID       string
	NodeName     string
}

func ListAppInstallationNodeReferences

func ListAppInstallationNodeReferences(installationID uuid.UUID) ([]WorkflowNodeReference, error)

type WorkflowNodeRequest

type WorkflowNodeRequest struct {
	ID          uuid.UUID
	WorkflowID  uuid.UUID
	NodeID      string
	ExecutionID *uuid.UUID
	State       string
	Type        string
	Spec        datatypes.JSONType[NodeExecutionRequestSpec]
	RunAt       time.Time
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

func FindPendingRequestForNode

func FindPendingRequestForNode(tx *gorm.DB, workflowID uuid.UUID, nodeID string) (*WorkflowNodeRequest, error)

func ListNodeRequests

func ListNodeRequests() ([]WorkflowNodeRequest, error)

func LockNodeRequest

func LockNodeRequest(tx *gorm.DB, id uuid.UUID) (*WorkflowNodeRequest, error)

func (*WorkflowNodeRequest) Complete

func (r *WorkflowNodeRequest) Complete(tx *gorm.DB) error

Jump to

Keyboard shortcuts

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