core

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOutputChannel = OutputChannel{Name: "default", Label: "Default"}

Functions

This section is empty.

Types

type Action

type Action struct {
	Name           string
	Description    string
	UserAccessible bool
	Parameters     []configuration.Field
}

* Custom action definition for a component.

type ActionContext

type ActionContext struct {
	Name           string
	Configuration  any
	Parameters     map[string]any
	Logger         *log.Entry
	HTTP           HTTPContext
	Metadata       MetadataContext
	ExecutionState ExecutionStateContext
	Auth           AuthContext
	Requests       RequestContext
	Integration    IntegrationContext
	Notifications  NotificationContext
}

* ActionContext allows the component to execute a custom action, * and control the state and metadata of each execution of it.

type AuthContext

type AuthContext interface {
	AuthenticatedUser() *User
	GetUser(id uuid.UUID) (*User, error)
	HasRole(role string) (bool, error)
	InGroup(group string) (bool, error)
}

type BrowserAction

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

type CleanupWebhookContext added in v0.0.30

type CleanupWebhookContext struct {
	HTTP        HTTPContext
	Webhook     WebhookContext
	Integration IntegrationContext
}

type Component

type Component interface {

	/*
	 * The unique identifier for the component.
	 * This is how nodes reference it, and is used for registration.
	 */
	Name() string

	/*
	 * The label for the component.
	 * This is how nodes are displayed in the UI.
	 */
	Label() string

	/*
	 * A good description of what the component does.
	 * Helpful for documentation and user interfaces.
	 */
	Description() string

	/*
	 * Detailed markdown documentation explaining how to use the component.
	 * This should provide in-depth information about the component's purpose,
	 * configuration options, use cases, and examples.
	 */
	Documentation() string

	/*
	 * The icon for the component.
	 * This is used in the UI to represent the component.
	 */
	Icon() string

	/*
	 * The color for the component.
	 * This is used in the UI to represent the component.
	 */
	Color() string

	/*
	 * Example output data for the component.
	 */
	ExampleOutput() map[string]any

	/*
	 * The output channels used by the component.
	 * If none is returned, the 'default' one is used.
	 */
	OutputChannels(configuration any) []OutputChannel

	/*
	 * The configuration fields exposed by the component.
	 */
	Configuration() []configuration.Field

	/*
	 * Setup the component.
	 */
	Setup(ctx SetupContext) error

	/*
	 * ProcessQueueItem is called when a queue item for this component's node
	 * is ready to be processed. Implementations should create the appropriate
	 * execution or handle the item synchronously using the provided context.
	 */
	ProcessQueueItem(ctx ProcessQueueContext) (*uuid.UUID, error)

	/*
	 * Passes full execution control to the component.
	 *
	 * Component execution has full control over the execution state,
	 * so it is the responsibility of the component to control it.
	 *
	 * Components should finish the execution or move it to waiting state.
	 * Components can also implement async components by combining Execute() and HandleAction().
	 */
	Execute(ctx ExecutionContext) error

	/*
	 * Allows components to define custom actions
	 * that can be called on specific executions of the component.
	 */
	Actions() []Action

	/*
	 * Execution a custom action - defined in Actions() -
	 * on a specific execution of the component.
	 */
	HandleAction(ctx ActionContext) error

	/*
	 * Handler for webhooks.
	 */
	HandleWebhook(ctx WebhookRequestContext) (int, error)

	/*
	 * Cancel allows components to handle cancellation of executions.
	 * Default behavior does nothing. Components can override to perform
	 * cleanup or cancel external resources.
	 */
	Cancel(ctx ExecutionContext) error
}

type EventContext

type EventContext interface {
	Emit(payloadType string, payload any) error
}

type ExecutionContext

type ExecutionContext struct {
	ID             uuid.UUID
	WorkflowID     string
	OrganizationID string
	NodeID         string
	SourceNodeID   string
	BaseURL        string
	Data           any
	Configuration  any
	ExpressionEnv  func(expression string) (map[string]any, error)
	Logger         *log.Entry
	HTTP           HTTPContext
	Metadata       MetadataContext
	NodeMetadata   MetadataContext
	ExecutionState ExecutionStateContext
	Requests       RequestContext
	Auth           AuthContext
	Integration    IntegrationContext
	Notifications  NotificationContext
}

* ExecutionContext allows the component * to control the state and metadata of each execution of it.

type ExecutionStateContext

type ExecutionStateContext interface {
	IsFinished() bool
	SetKV(key, value string) error

	/*
	 * Pass the execution, emitting a payload to the specified channel.
	 */
	Emit(channel, payloadType string, payloads []any) error

	/*
	 * Pass the execution, without emitting any payloads from it.
	 */
	Pass() error

	/*
	 * Fails the execution.
	 * No payloads are emitted.
	 */
	Fail(reason, message string) error
}

* ExecutionStateContext allows components to control execution lifecycle.

type HTTPContext added in v0.0.43

type HTTPContext interface {
	Do(*http.Request) (*http.Response, error)
}

* Components / triggers / applications should always * use this context instead of the net/http directly for executing HTTP requests. * * This makes it easy for us to write unit tests for the implementations, * and also makes it easier to control HTTP timeouts for everything in one place.

type HTTPRequestContext

type HTTPRequestContext struct {
	Logger          *logrus.Entry
	Request         *http.Request
	Response        http.ResponseWriter
	OrganizationID  string
	BaseURL         string
	WebhooksBaseURL string
	HTTP            HTTPContext
	Integration     IntegrationContext
}

type Integration added in v0.5.0

type Integration interface {
	/*
	 * The name of the integration.
	 */
	Name() string

	/*
	 * Display name for the integration.
	 */
	Label() string

	/*
	 * The icon used by the integration.
	 */
	Icon() string

	/*
	 * A description of what the integration does.
	 */
	Description() string

	/*
	 * Markdown-formatted instructions shown in the connection modal.
	 */
	Instructions() string

	/*
	 * The configuration fields of the integration.
	 */
	Configuration() []configuration.Field

	/*
	 * The list of components exposed by the integration.
	 */
	Components() []Component

	/*
	 * The list of triggers exposed by the integration.
	 */
	Triggers() []Trigger

	/*
	 * Called when configuration changes.
	 */
	Sync(ctx SyncContext) error

	/*
	 * List resources of a given type.
	 */
	ListResources(resourceType string, ctx ListResourcesContext) ([]IntegrationResource, error)

	/*
	 * HTTP request handler
	 */
	HandleRequest(ctx HTTPRequestContext)

	/*
	 * Used to compare webhook configurations.
	 * If the configuration is the same,
	 * the system will reuse the existing webhook.
	 */
	CompareWebhookConfig(a, b any) (bool, error)

	/*
	 * Set up webhooks through the integration, in the external system.
	 * This is called by the webhook provisioner, for pending webhook records.
	 */
	SetupWebhook(ctx SetupWebhookContext) (any, error)

	/*
	 * Delete webhooks through the integration, in the external system.
	 * This is called by the webhook cleanup worker, for webhook records that were deleted.
	 */
	CleanupWebhook(ctx CleanupWebhookContext) error
}

type IntegrationComponent added in v0.5.0

type IntegrationComponent interface {

	/*
	 * IntegrationComponent inherits all the methods from Component interface,
	 * and adds a couple more, which are only applicable to app components.
	 */
	Component

	OnIntegrationMessage(ctx IntegrationMessageContext) error
}

type IntegrationContext

type IntegrationContext interface {

	//
	// Control the metadata and config of the integration
	//
	ID() uuid.UUID
	GetMetadata() any
	SetMetadata(any)
	GetConfig(name string) ([]byte, error)

	//
	// Control the state of the integration
	//
	GetState() string
	SetState(state, stateDescription string)

	//
	// Control the browser action of the integration
	//
	NewBrowserAction(action BrowserAction)
	RemoveBrowserAction()

	//
	// Control the secrets of the integration
	//
	SetSecret(name string, value []byte) error
	GetSecrets() ([]IntegrationSecret, error)

	/*
	 * Request a new webhook from the integration.
	 * Called from the components/triggers Setup().
	 */
	RequestWebhook(configuration any) error

	/*
	 * Subscribe to integration events.
	 */
	Subscribe(any) (*uuid.UUID, error)

	/*
	 * Schedule a sync call for the integration.
	 */
	ScheduleResync(interval time.Duration) error

	/*
	 * List integration subscriptions from nodes.
	 */
	ListSubscriptions() ([]IntegrationSubscriptionContext, error)
}

* IntegrationContext allows components to access integration information.

type IntegrationMessageContext added in v0.5.0

type IntegrationMessageContext struct {
	Message       any
	Configuration any
	Logger        *logrus.Entry
	Integration   IntegrationContext
	Events        EventContext
}

type IntegrationResource added in v0.5.0

type IntegrationResource struct {
	Type string
	Name string
	ID   string
}

type IntegrationSecret added in v0.5.0

type IntegrationSecret struct {
	Name  string
	Value []byte
}

type IntegrationSubscriptionContext added in v0.5.0

type IntegrationSubscriptionContext interface {
	Configuration() any
	SendMessage(any) error
}

type IntegrationTrigger added in v0.5.0

type IntegrationTrigger interface {

	/*
	 * Inherits all the methods from Trigger interface,
	 * and adds a couple more, which are only applicable to integration triggers.
	 */
	Trigger

	OnIntegrationMessage(ctx IntegrationMessageContext) error
}

type ListResourcesContext added in v0.0.43

type ListResourcesContext struct {
	Logger      *logrus.Entry
	HTTP        HTTPContext
	Integration IntegrationContext
}

type MetadataContext

type MetadataContext interface {
	Get() any
	Set(any) error
}

* MetadataContext allows components to store/retrieve * component-specific information about each execution.

type NodeWebhookContext added in v0.0.30

type NodeWebhookContext interface {
	Setup() (string, error)
	GetSecret() ([]byte, error)
	ResetSecret() ([]byte, []byte, error)
	GetBaseURL() string
}

type NotificationContext added in v0.0.43

type NotificationContext interface {
	Send(title, body, url, urlLabel string, receivers NotificationReceivers) error
}

type NotificationReceivers added in v0.0.43

type NotificationReceivers struct {
	Emails []string
	Groups []string
	Roles  []string
}

type OutputChannel

type OutputChannel struct {
	Name        string
	Label       string
	Description string
}

type ProcessQueueContext

type ProcessQueueContext struct {
	WorkflowID    string
	NodeID        string
	RootEventID   string
	EventID       string
	SourceNodeID  string
	Configuration any
	Input         any
	ExpressionEnv func(expression string) (map[string]any, error)

	//
	// Deletes the queue item
	//
	DequeueItem func() error

	//
	// Updates the state of the node
	//
	UpdateNodeState func(state string) error

	//
	// Creates a pending execution for this queue item.
	//
	CreateExecution func() (*ExecutionContext, error)

	//
	// Finds an execution by a key-value pair.
	// Returns an ExecutionContext.
	//
	FindExecutionByKV func(key string, value string) (*ExecutionContext, error)

	//
	// DefaultProcessing performs the default processing for the queue item.
	// Convenience method to avoid boilerplate in components that just want default behavior,
	// where an execution is created and the item is dequeued.
	//
	DefaultProcessing func() (*uuid.UUID, error)

	//
	// CountDistinctIncomingSources returns the number of distinct upstream
	// source nodes connected to this node (ignoring multiple channels from the
	// same source)
	//
	CountDistinctIncomingSources func() (int, error)
}

* ProcessQueueContext is provided to components to process a node's queue item. * It mirrors the data the queue worker would otherwise use to create executions.

type RequestContext

type RequestContext interface {

	//
	// Allows the scheduling of a certain component action at a later time
	//
	ScheduleActionCall(actionName string, parameters map[string]any, interval time.Duration) error
}

* RequestContext allows the execution to schedule * work with the processing engine.

type SetupContext

type SetupContext struct {
	Logger        *log.Entry
	Configuration any
	HTTP          HTTPContext
	Metadata      MetadataContext
	Requests      RequestContext
	Auth          AuthContext
	Integration   IntegrationContext
}

* ExecutionContext allows the component * to control the state and metadata of each execution of it.

type SetupWebhookContext added in v0.0.30

type SetupWebhookContext struct {
	HTTP        HTTPContext
	Webhook     WebhookContext
	Logger      *logrus.Entry
	Integration IntegrationContext
}

type SyncContext

type SyncContext struct {
	Configuration   any
	BaseURL         string
	WebhooksBaseURL string
	OrganizationID  string
	InstallationID  string
	HTTP            HTTPContext
	Integration     IntegrationContext
	OIDC            oidc.Provider
}

type Trigger

type Trigger interface {

	/*
	 * The unique identifier for the trigger.
	 * This is how nodes reference it, and is used for registration.
	 */
	Name() string

	/*
	 * The label for the trigger.
	 * This is how nodes are displayed in the UI.
	 */
	Label() string

	/*
	 * A good description of what the trigger does.
	 * Helpful for documentation and user interfaces.
	 */
	Description() string

	/*
	 * Detailed markdown documentation explaining how to use the trigger.
	 * This should provide in-depth information about the trigger's purpose,
	 * configuration options, use cases, and examples.
	 */
	Documentation() string

	/*
	 * The icon for the trigger.
	 */
	Icon() string

	/*
	 * The color for the trigger.
	 */
	Color() string

	/*
	 * Example input data for the trigger.
	 */
	ExampleData() map[string]any

	/*
	 * The configuration fields exposed by the trigger.
	 */
	Configuration() []configuration.Field

	/*
	 * Handler for webhooks
	 */
	HandleWebhook(ctx WebhookRequestContext) (int, error)

	/*
	 * Setup the trigger.
	 */
	Setup(ctx TriggerContext) error

	/*
	 * Allows triggers to define custom actions.
	 */
	Actions() []Action

	/*
	 * Execution a custom action - defined in Actions() for a trigger.
	 */
	HandleAction(ctx TriggerActionContext) (map[string]any, error)
}

type TriggerActionContext

type TriggerActionContext struct {
	Name          string
	Parameters    map[string]any
	Configuration any
	Logger        *log.Entry
	HTTP          HTTPContext
	Metadata      MetadataContext
	Requests      RequestContext
	Events        EventContext
	Webhook       NodeWebhookContext
	Integration   IntegrationContext
}

type TriggerContext

type TriggerContext struct {
	Logger        *log.Entry
	Configuration any
	HTTP          HTTPContext
	Metadata      MetadataContext
	Requests      RequestContext
	Events        EventContext
	Webhook       NodeWebhookContext
	Integration   IntegrationContext
}

type User

type User struct {
	ID    string `mapstructure:"id" json:"id"`
	Name  string `mapstructure:"name" json:"name"`
	Email string `mapstructure:"email" json:"email"`
}

type WebhookContext

type WebhookContext interface {
	GetID() string
	GetURL() string
	GetSecret() ([]byte, error)
	GetMetadata() any
	GetConfiguration() any
	SetSecret([]byte) error
}

* WebhookContext allows implementations to read/manage Webhook records.

type WebhookOptions

type WebhookOptions struct {
	ID            string
	URL           string
	Secret        []byte
	Configuration any
	Metadata      any
}

type WebhookRequestContext

type WebhookRequestContext struct {
	Body          []byte
	Headers       http.Header
	WorkflowID    string
	NodeID        string
	Configuration any
	Webhook       NodeWebhookContext
	Events        EventContext

	//
	// Return an execution context for a given execution,
	// through a referencing key-value pair.
	//
	FindExecutionByKV func(key string, value string) (*ExecutionContext, error)
}

type Widget added in v0.0.18

type Widget interface {

	/*
	 * The unique identifier for the widget.
	 * This is how nodes reference it, and is used for registration.
	 */
	Name() string

	/*
	 * The label for the widget.
	 * This is how nodes are displayed in the UI.
	 */
	Label() string

	/*
	 * A good description of what the widget does.
	 * Helpful for documentation and user interfaces.
	 */
	Description() string

	/*
	 * The icon for the widget.
	 */
	Icon() string

	/*
	 * The color for the widget.
	 */
	Color() string

	/*
	 * The configuration fields exposed by the widget.
	 */
	Configuration() []configuration.Field
}

* Widgets are used to represent every node not event or execution related. * Use it to display and group data in the UI canvas.

Jump to

Keyboard shortcuts

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