sdk

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(url string) (*grab.Response, error)

DownloadFile downloads a file from the specified URL using the grab package. It returns the grab.Response object and an error if any.

func DynamicInputToType

func DynamicInputToType[T any](ctx *sdkcore.DynamicFieldContext) *T

DynamicInputToType converts the resolved input of type `sdkcore.DynamicOptionsContext` to the desired type T. It uses JSON marshaling and unmarshalling to perform the conversion. If any error occurs during marshaling or unmarshaling, it returns nil. The function returns a pointer to the converted value of type T.

func GetRelativePathWithDepth

func GetRelativePathWithDepth(relativePath string, depth int) (string, error)

GetRelativePathWithDepth resolves a file path relative to the location of the caller, with adjustable depth.

func InputPropsToType

func InputPropsToType[T any](input sdkcore.JSON) (*T, error)

InputPropsToType returns a pointer to a value of type T by marshaling and unmarshaling the ResolvedInput field of the provided RunContext struct. If there is an error during the marshaling or unmarshaling process, nil is returned. The function signature is as follows:

func InputToType

func InputToType[T any](ctx BaseContext) *T

InputToType returns a pointer to a value of type T by marshaling and unmarshaling the ResolvedInput field of the provided RunContext struct. If there is an error during the marshaling or unmarshaling process, nil is returned. The function signature is as follows:

func InputToTypeSafely

func InputToTypeSafely[T any](ctx BaseContext) (*T, error)

InputToTypeSafely returns a pointer to a value of type T by marshaling and unmarshaling the ResolvedInput field of the provided RunContext struct. If there is an error during the marshaling or unmarshaling process, nil is returned. The function signature is as follows:

func ReadREADME

func ReadREADME(content string) (string, error)

ReadREADME extracts the content of README.md from the current directory.

func StringToFile

func StringToFile(fileStr string) (*autoform.File, error)

StringToFile converts a file string to a *autoform.File object.

The function checks if the file string is a base64-encoded data or a URL. If the file string is base64-encoded data, it decodes the data and assigns it to the `Data` field of the

Types

type Action

type Action interface {
	BaseOperation

	// Perform executes the action with the given input schema and returns a result or an error.
	Perform(ctx PerformContext) (oldcore.JSON, error)

	// GetType returns the trigger type (e.g., BRANCH, BOOLEAN, FLOW, STEP).
	GetType() oldcore.ActionType

	// Settings provides operation-specific configuration details necessary for executing the action.
	Settings() oldcore.ActionSettings
}

Action defines a generic interface for performing an operation within the sdk.

type Auth

type Auth = oldcore.OperationAuth

type BaseContext

type BaseContext struct {
	Auth *sdkcore.AuthContext `json:"auth"`

	Files         FileManager
	ExecutionMode ExecutionMode `json:"execution_mode"`
	// contains filtered or unexported fields
}

func NewBaseContext

func NewBaseContext(
	ctx context.Context,
	files FileManager,
	meta *ExecuteMetadata,
	auth *sdkcore.AuthContext,
	resolvedInput sdkcore.JSON,
	input map[string]any,
	log sdkcore.Logger,
) *BaseContext

func (*BaseContext) GetRawInput

func (r *BaseContext) GetRawInput() sdkcore.JSONObject

GetRawInput returns a boolean value indicating whether the execution is currently paused. It checks the value of the 'isPaused' field in the RunContext struct.

func (*BaseContext) Input

func (r *BaseContext) Input() any

Input returns a boolean value indicating whether the execution is currently paused. It checks the value of the 'isPaused' field in the RunContext struct.

func (*BaseContext) Log

func (r *BaseContext) Log() sdkcore.Logger

func (*BaseContext) Metadata

func (r *BaseContext) Metadata() ExecuteMetadata

Metadata returns a boolean value indicating whether the execution is currently paused. It checks the value of the 'isPaused' field in the RunContext struct.

func (*BaseContext) RawInput

func (r *BaseContext) RawInput() map[string]any

type BaseOperation

type BaseOperation interface {
	// Name returns the human-readable name for the sdk (e.g., "Slack", "Stripe").
	Name() string

	// The Description returns a detailed explanation or summary of the trigger or action being executed.
	Description() string

	// Documentation returns an OperationDocumentation instance, providing optional detailed documentation for the operation.
	Documentation() *OperationDocumentation

	// Icon returns a pointer to a string representing the icon for the sdk or operation.
	Icon() *string

	// SampleData retrieves example or mock data related to the operation, often used for testing or sdk scenarios.
	// Returns a pointer to the JSON data and an error if the retrieval fails.
	SampleData() oldcore.JSON

	// Properties returns a map of property names to their corresponding AutoFormSchema definitions.
	Properties() map[string]*oldcore.AutoFormSchema

	// Auth returns the authentication schema required for the operation, defined as an AutoFormSchema.
	Auth() *Auth
}

type DerivedDocumentation

type DerivedDocumentation struct {
	Documentation string
	Actions       map[string]OperationDocumentation
	Triggers      map[string]OperationDocumentation
}

type ExecuteContext

type ExecuteContext struct {
	BaseContext
}

func NewExecuteContext

func NewExecuteContext(
	ctx context.Context,
	files FileManager,
	meta *ExecuteMetadata,
	auth *sdkcore.AuthContext,
	resolvedInput sdkcore.JSON,
	input map[string]any,
	log sdkcore.Logger,
) *ExecuteContext

func (*ExecuteContext) GetPauseTime

func (r *ExecuteContext) GetPauseTime() *time.Time

GetPauseTime returns the paused time in the RunContext. It retrieves the value from the pausedTime field in the RunContext struct.

func (*ExecuteContext) IsPaused

func (r *ExecuteContext) IsPaused() bool

IsPaused returns a boolean value indicating whether the execution is currently paused. It checks the value of the 'isPaused' field in the RunContext struct.

func (*ExecuteContext) PauseExecution

func (r *ExecuteContext) PauseExecution() (sdkcore.JSON, error)

PauseExecution pauses the execution of the RunContext. It sets the isPaused field of the RunContext to true and the pausedTime field to the provided resume time from the PauseMetadata. It returns a pointer to a PauseMetadataFull object and nil error.

type ExecuteMetadata

type ExecuteMetadata struct {
	FlowVersionID xid.ID `json:"flowVersionId,omitempty"`
	// FlowID holds the value of the "flow_id" field.
	FlowID xid.ID  `json:"flowId"`
	RunID  *xid.ID `json:"runId,omitempty"`
	// Name holds the value of the "name" field.
	StepName string `json:"stepName,omitempty"`
	// LastRun field stores the timestamp of the last run of a flow version.
	LastRun *time.Time `json:"last_run,omitempty"`
	// Status indicates the current state of the flow version, represented by the FlowVersionState enumeration.
	FlowStatus oldcore.FlowVersionState `json:"flowStatus"`
	// ProjectID holds the value of the "project_id" field.
	ProjectID xid.ID `json:"projectId"`
	// Mode specifies the mode of execution, represented by the ExecutionMode type, and serialized as "mode" in JSON.
	Mode ExecutionMode `json:"mode"`
}

type ExecutionMode

type ExecutionMode = sdkcore.ExecutionMode

type FileManager

type FileManager interface {
	Put(name string, data io.Reader) (*string, error)
	PutFlow(metadata *ExecuteMetadata, name string, data io.Reader) (*string, error)
	ReadFlow(metadata *ExecuteMetadata, name string) ([]byte, error)
	Read(name string) ([]byte, error)
}

type Integration

type Integration interface {
	// Auth returns the authentication schema configuration required by the sdk.
	Auth() *Auth

	// Triggers returns all triggers supported by this sdk.
	Triggers() []Trigger

	// Actions returns all actions supported by this sdk.
	Actions() []Action
}

Integration defines an interface for managing a set of triggers and actions for a specific system or service.

type IntegrationSchemaModel

type IntegrationSchemaModel struct {
	Name        string   `json:"name" toml:"name" yaml:"name" validate:"required"`
	Description string   `json:"description" toml:"description"  yaml:"description" validate:"required"`
	Version     string   `json:"version" toml:"version" yaml:"version" validate:"required"`
	Authors     []string `json:"authors" toml:"authors" yaml:"authors" validate:"required"`
	Website     *string  `json:"website" toml:"website" yaml:"website"`
	Categories  []string `json:"categories" toml:"categories" yaml:"categories" validate:"required"`
	Icon        string   `json:"icon" toml:"icon" yaml:"icon" validate:"required"`
}

func ReadFloFile

func ReadFloFile(content string) (*IntegrationSchemaModel, error)

type JSON

type JSON = oldcore.JSON

type JSONOutput

type JSONOutput any

type LifecycleContext

type LifecycleContext struct {
	BaseContext
	Ack  func(output sdkcore.JSON) error
	Nack func(err error) error
}

type OperationContextFn

type OperationContextFn = func() (*JSONOutput, error)

type OperationDocumentation

type OperationDocumentation struct {
	Documentation *string `json:"documentation,omitempty"`
}

type OperationMetadata

type OperationMetadata struct {
	// Description holds the value of the "description" field.
	Description string `json:"description,omitempty" validate:"required"`
	// HelpText holds the value of the "helpText" field.
	HelpText *string `json:"helpText,omitempty"`
	// SampleOutput holds the value of the "sampleOutput" field.
	SampleOutput map[string]any `json:"sampleOutput,omitempty"`
	// Auth holds the value of the "auth" field.
	Auth *oldcore.AutoFormSchema `json:"auth,omitempty"`
}

type PerformContext

type PerformContext struct {
	BaseContext
}

type Registration

type Registration struct {
	Version Integration
	Info    RegistrationInfo
}

func Register

func Register(integration Integration, flow string, readme string) *Registration

type RegistrationFn

type RegistrationFn = []func() (Registration, error)

type RegistrationInfo

type RegistrationInfo struct {
	IntegrationSchemaModel
	DisplayName   string               `json:"displayName"`
	Documentation DerivedDocumentation `json:"documentation"`
}

type RegistrationMap

type RegistrationMap struct {
	Versions map[string]Registration
	Info     RegistrationInfo
}

type ScheduledOutput

type ScheduledOutput = oldcore.OldScheduleTriggerCriteria

func OutputScheduled

func OutputScheduled(criteria ScheduledOutput) ScheduledOutput

type SchemaConfig

type SchemaConfig struct {
	Integration IntegrationSchemaModel `json:"integration" toml:"integration" yaml:"integration" validate:"required"`
}

type StepRunState

type StepRunState struct {
	// ID of the ent.
	ID xid.ID `json:"id,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// ProjectID holds the value of the "team_id" field.
	ProjectID xid.ID `json:"project_id,omitempty"`
	// Status holds the value of the "status" field.
	Status oldcore.StepRunStatus `json:"status,omitempty"`
	// Order holds the value of the "order" field.
	Order int `json:"order,omitempty"`
	// FlowID holds the value of the "flow_id" field.
	FlowID xid.ID `json:"flow_id,omitempty"`
	// FlowVersionID holds the value of the "flow_version_id" field.
	FlowVersionID xid.ID `json:"flow_version_id,omitempty"`
	// RunID holds the value of the "run_id" field.
	RunID xid.ID `json:"run_id,omitempty"`
	// ConnectorName holds the value of the "connector_name" field.
	ConnectorName string `json:"connector_name,omitempty"`
	// ConnectorVersion holds the value of the "connector_version" field.
	ConnectorVersion string `json:"connector_version,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Input holds the value of the "input" field.
	Input map[string]interface{} `json:"input,omitempty"`
	// Errors holds the value of the "errors" field.
	Errors []oldcore.StateError `json:"errors,omitempty"`
	// Output holds the value of the "output" field.
	Output oldcore.JSON `json:"output,omitempty"`
	// StartTime represents the start time of a step run.
	StartTime *time.Time `json:"start_time,omitempty"`
	// EndTime represents the end time of a step run.
	// It is a pointer to a time.Time value and can be nil.
	Duration *int64 `json:"duration,omitempty"`
	// EndTime represents the end time of a step run.
	// It is a pointer to a time.Time value and can be nil.
	EndTime *time.Time `json:"end_time,omitempty"`
	// Type represents the type of the flow step, defined by the FlowStepType enumeration, such as STEP, LOOP, or ROUTER.
	Type          oldcore.FlowStepType `json:"type,omitempty"`
	ExecutionMode ExecutionMode        `json:"mode,omitempty"`
}

type Trigger

type Trigger interface {
	BaseOperation

	// Start prepares and activates the trigger (e.g., start polling, event listening, cron schedules, etc.).
	Start(ctx LifecycleContext) error

	// Stop gracefully stops or disables the trigger (e.g., unsubscribe or clean up resources).
	Stop(ctx LifecycleContext) error

	// Execute handles the trigger's action when manually invoked with an input schema.
	Execute(ctx ExecuteContext) (oldcore.JSON, error)

	// GetType returns the trigger type (e.g., POLLING, EVENT, WEBHOOK, MANUAL, SCHEDULED).
	GetType() oldcore.TriggerType

	// Criteria Additional criteria or filter rules required to activate the trigger.
	Criteria(ctx context.Context) oldcore.OldTriggerCriteria
}

Trigger defines a generic interface for workflow triggers.

type WebhookOutput

type WebhookOutput = oldcore.OldWebhookTriggerCriteria

func OutputWebhook

func OutputWebhook(criteria WebhookOutput) WebhookOutput

Jump to

Keyboard shortcuts

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