Documentation
¶
Index ¶
- type AuthContext
- func (c *AuthContext) GetCustomAuth() (map[string]string, error)
- func (c *AuthContext) GetExtra() (map[string]string, error)
- func (c *AuthContext) WithExtraParam(key, value string) *AuthContext
- func (c *AuthContext) WithKey(key string) *AuthContext
- func (c *AuthContext) WithScopes(scopes []string) *AuthContext
- func (c *AuthContext) WithSecret(secret string) *AuthContext
- func (c *AuthContext) WithUsernamePassword(username, password string) *AuthContext
- type BaseContext
- type DynamicFieldContext
- type ExecuteContext
- type LifecycleContext
- type PerformContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthContext ¶
type AuthContext struct {
// Access token for OAuth2 and token-based authentication
AccessToken string `json:"accessToken,omitempty"`
// Full OAuth2 token data
Token *oauth2.Token `json:"token,omitempty"`
// Token source for refreshing OAuth2 tokens
TokenSource *oauth2.TokenSource `json:"tokenSource,omitempty"`
// Token type (Bearer, MAC, etc.)
TokenType string `json:"tokenType,omitempty"`
// Basic auth credentials
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
// API key and secret
Secret string `json:"secret,omitempty"`
Key string `json:"key,omitempty"`
// OAuth2 scopes
Scopes []string `json:"scopes,omitempty"`
// Additional parameters for custom auth types
Extra map[string]string `json:"extra,omitempty"`
}
AuthContext provides authentication data for API calls
func NewAuthContext ¶
func NewAuthContext(accessToken string) *AuthContext
NewAuthContext creates a basic AuthContext with the given token
func (*AuthContext) GetCustomAuth ¶
func (c *AuthContext) GetCustomAuth() (map[string]string, error)
GetCustomAuth retrieves custom authentication data
func (*AuthContext) GetExtra ¶
func (c *AuthContext) GetExtra() (map[string]string, error)
GetExtra retrieves additional parameters from the auth context
func (*AuthContext) WithExtraParam ¶
func (c *AuthContext) WithExtraParam(key, value string) *AuthContext
WithExtraParam adds a parameter to the context
func (*AuthContext) WithKey ¶
func (c *AuthContext) WithKey(key string) *AuthContext
WithKey adds an API key to the context
func (*AuthContext) WithScopes ¶
func (c *AuthContext) WithScopes(scopes []string) *AuthContext
WithScopes adds OAuth2 scopes to the context
func (*AuthContext) WithSecret ¶
func (c *AuthContext) WithSecret(secret string) *AuthContext
WithSecret adds a secret to the context
func (*AuthContext) WithUsernamePassword ¶
func (c *AuthContext) WithUsernamePassword(username, password string) *AuthContext
WithUsernamePassword adds basic auth credentials to the context
type BaseContext ¶ added in v0.11.0
type BaseContext interface {
// Context returns the underlying Go context for the execution operation.
Context() context.Context
// Logger returns a structured logger for the execution.
Logger() core.Logger
// Input returns the validated input data for the trigger execution.
Input() core.JSONObject
// AuthContext provides authentication context for the trigger execution.
AuthContext() (*AuthContext, error)
// Auth provides authentication context for the trigger execution.
Auth() *AuthContext
}
type DynamicFieldContext ¶ added in v0.11.0
type DynamicFieldContext interface {
BaseContext
// Respond sends a response containing the provided data and total count of items, adhering to dynamic options structure.
// Returns a `DynamicOptionsResponse` object with items and metadata or an error if processing the response fails.
Respond(data any, totalItems int) (*core.DynamicOptionsResponse, error)
// RespondJSON creates a JSON response containing the provided data and total item count. Returns the JSON or an error.
RespondJSON(data any, totalItems int) (core.JSON, error)
// WorkflowID returns the unique identifier of the workflow.
WorkflowID() xid.ID
// WorkflowVersionID returns the unique identifier of the workflow version.
WorkflowVersionID() xid.ID
// FieldName returns the name of the current field within the workflow context.
FieldName() string
// OperationID returns the unique identifier of the current operation within the workflow context.
OperationID() string
// StepID returns the unique identifier of the step in the workflow.
StepID() string
// Filter returns filtering parameters for dynamic options, including offset, limit, and filter term.
Filter() *core.DynamicOptionsFilterParams
}
DynamicFieldContext defines the interface for performing an action in a workflow. It provides methods for handling action execution, including input validation, authentication, output processing, and error handling.
type ExecuteContext ¶
type ExecuteContext interface {
BaseContext
// WorkflowID returns the unique identifier of the workflow.
WorkflowID() xid.ID
// WorkflowVersionID returns the unique identifier of the workflow version.
WorkflowVersionID() xid.ID
// ProjectID returns the unique identifier of the project.
ProjectID() xid.ID
// TriggerID returns the unique identifier of the trigger being executed.
TriggerID() string
// RunID returns the unique identifier of the current workflow run.
RunID() xid.ID
// Logger returns a structured logger for the execution.
Logger() core.Logger
// Logger returns a structured logger for the execution.
LastRun() *time.Time
// SetInput updates the input data for the trigger execution.
SetInput(input core.JSONObject) error
// Environment returns the environment for the trigger execution.
Environment() core.Environment
// Validate validates the input against the trigger's schema.
Validate() error
// EmitEvent allows triggers to emit events during execution.
EmitEvent(eventType string, payload core.JSON) error
// SetOutput sets the output data from the trigger execution.
SetOutput(output core.JSON) error
// PauseExecution pauses the workflow execution, to be resumed later.
PauseExecution(reason string) error
// SetMetadata stores execution metadata for the workflow run.
SetMetadata(key string, value interface{}) error
// GetMetadata retrieves stored execution metadata.
GetMetadata(key string) (interface{}, error)
// ExecutionState returns the current state of the execution.
ExecutionState() core.StepRunStatus
// Schema returns the input schema for the trigger.
Schema() *smartform.FormSchema
// Cancel signals that the execution should be canceled.
Cancel() error
// IsCanceled checks if the execution has been canceled.
IsCanceled() bool
}
ExecuteContext defines the interface for executing a trigger in a workflow. It provides methods for handling trigger execution, including input validation, authentication, and output processing.
type LifecycleContext ¶
type LifecycleContext interface {
// Context returns the underlying Go context for the lifecycle operation.
Context() context.Context
// WorkflowID returns the unique identifier of the workflow.
WorkflowID() xid.ID
// ProjectID returns the unique identifier of the project.
ProjectID() xid.ID
// TriggerID returns the unique identifier of the trigger being managed.
TriggerID() string
// Logger returns a structured logger for the trigger.
Logger() core.Logger
// Config returns the configuration for the trigger.
Config() map[string]interface{}
// Input returns the Input for the trigger.
Input() map[string]interface{}
// GetLastRunTime returns the timestamp of the last successful run.
GetLastRunTime() (*time.Time, error)
// SetLastRunTime updates the timestamp of the last successful run.
SetLastRunTime(time.Time) error
// GetState retrieves stored state for stateful triggers.
GetState() (map[string]interface{}, error)
// SetState stores state for stateful triggers.
SetState(map[string]interface{}) error
// TriggerCriteria returns the configured criteria for the trigger.
TriggerCriteria() (*core.TriggerCriteria, error)
// EmitEvent allows triggers to emit events that can be processed by the workflow runtime.
EmitEvent(payload core.JSON) error
// StoreMetadata allows triggers to store metadata about their execution.
StoreMetadata(key string, value interface{}) error
// GetMetadata retrieves stored metadata.
GetMetadata(key string) (interface{}, error)
// Cancel signals that the trigger should be canceled.
Cancel() error
// IsCanceled checks if the trigger has been canceled.
IsCanceled() bool
}
LifecycleContext defines the interface for trigger lifecycle management. It provides methods for handling the setup, teardown, and lifecycle state of triggers within a workflow.
type PerformContext ¶
type PerformContext interface {
BaseContext
// WorkflowID returns the unique identifier of the workflow.
WorkflowID() xid.ID
// WorkflowVersionID returns the unique identifier of the workflow version.
WorkflowVersionID() xid.ID
// ProjectID returns the unique identifier of the project.
ProjectID() xid.ID
// StepID returns the unique identifier of the step in the workflow.
StepID() string
// RunID returns the unique identifier of the current workflow run.
RunID() xid.ID
// StepRunID returns the unique identifier of the current step run.
StepRunID() xid.ID
// PreviousStepOutput returns the output from the previous step in the workflow.
PreviousStepOutput() (core.JSONObject, error)
// Validate validates the input against the action's schema.
Validate() error
// SetOutput sets the output data from the action.
SetOutput(output core.JSON) error
// PauseExecution pauses the workflow execution, to be resumed later.
PauseExecution(reason string, resumeAfter *time.Time) error
// SetMetadata stores execution metadata for the workflow run.
SetMetadata(key string, value interface{}) error
// GetMetadata retrieves stored execution metadata.
GetMetadata(key string) (interface{}, error)
// ExecutionState returns the current state of the execution.
ExecutionState() core.StepRunStatus
// Schema returns the input schema for the action.
Schema() *smartform.FormSchema
// Retry schedules the action to be retried after the specified duration.
Retry(after time.Duration, reason string) error
// MarkFailed marks the action as failed with a reason.
MarkFailed(reason string) error
// Cancel signals that the action should be canceled.
Cancel() error
// IsCanceled checks if the action has been canceled.
IsCanceled() bool
// WorkflowContext returns the workflow context data for the current run.
WorkflowContext() (map[string]interface{}, error)
// UpdateWorkflowContext updates the workflow context data.
UpdateWorkflowContext(data map[string]interface{}) error
}
PerformContext defines the interface for performing an action in a workflow. It provides methods for handling action execution, including input validation, authentication, output processing, and error handling.