Documentation ¶
Index ¶
- Variables
- func CreateTrigger(args CreateTriggerArgs)
- func DownloadFile(url string) (*grab.Response, error)
- func DynamicInputToType[T any](ctx *sdkcore.DynamicFieldContext) *T
- func InputToType[T any](ctx *RunContext) *T
- func InputToTypeSafely[T any](ctx *RunContext) (*T, error)
- func StringToFile(fileStr string) (*autoform.File, error)
- func ValidateConnectorInfo(info *CreateConnectorArgs) error
- func ValidateOperationInfo(info *OperationInfo) error
- func ValidateTriggerInfo(info *TriggerInfo) error
- type ConnectorCategory
- func (_j ConnectorCategory) IsValid() bool
- func (_j ConnectorCategory) MarshalBinary() ([]byte, error)
- func (_j ConnectorCategory) MarshalGQL(w io.Writer)
- func (_j ConnectorCategory) MarshalJSON() ([]byte, error)
- func (_j ConnectorCategory) MarshalText() ([]byte, error)
- func (_j ConnectorCategory) MarshalYAML() (interface{}, error)
- func (ConnectorCategory) SQLTypeName() string
- func (_j *ConnectorCategory) Scan(value interface{}) error
- func (_j ConnectorCategory) String() string
- func (_j *ConnectorCategory) UnmarshalBinary(text []byte) error
- func (_j *ConnectorCategory) UnmarshalGQL(value interface{}) error
- func (_j *ConnectorCategory) UnmarshalJSON(data []byte) error
- func (_j *ConnectorCategory) UnmarshalText(text []byte) error
- func (_j *ConnectorCategory) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (_j ConnectorCategory) Validate() error
- func (ConnectorCategory) Values() []string
- type ConnectorMetadata
- type ConnectorPlugin
- type CreateConnectorArgs
- type CreateIOperationArgs
- type CreateTriggerArgs
- type IConnectorPlugin
- type IOperation
- type IRunnable
- type ITrigger
- type JSON
- type OperationInfo
- type PauseMetadata
- type PauseMetadataFull
- type RunContext
- type SpiderTestRuntime
- func (s *SpiderTestRuntime) Close() error
- func (s *SpiderTestRuntime) GetConfig() *ConnectorMetadata
- func (s *SpiderTestRuntime) OperationConfig(name string) *sdkcore.Operation
- func (s *SpiderTestRuntime) Operations() []*sdkcore.Operation
- func (s *SpiderTestRuntime) RunAuth() error
- func (s *SpiderTestRuntime) RunOperation(name string, run *RunContext) (JSON, error)
- func (s *SpiderTestRuntime) RunTrigger(name string, run *RunContext) (JSON, error)
- func (s *SpiderTestRuntime) TriggerConfig(name string) *sdkcore.Trigger
- func (s *SpiderTestRuntime) Triggers() []*sdkcore.Trigger
- type TriggerInfo
- type TriggerRunContext
Constants ¶
This section is empty.
Variables ¶
var ErrNoValidEnum = errors.New("not a valid enum")
Functions ¶
func CreateTrigger ¶
func CreateTrigger(args CreateTriggerArgs)
func DownloadFile ¶
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 InputToType ¶
func InputToType[T any](ctx *RunContext) *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 ¶ added in v0.2.7
func InputToTypeSafely[T any](ctx *RunContext) (*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 StringToFile ¶
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
func ValidateConnectorInfo ¶
func ValidateConnectorInfo(info *CreateConnectorArgs) error
ValidateConnectorInfo validates the connector information provided
func ValidateOperationInfo ¶
func ValidateOperationInfo(info *OperationInfo) error
ValidateOperationInfo validates the provided OperationInfo. It checks if the OperationInfo is nil, if the name is missing, and if the description is missing. Returns an error if any of the checks fail, or nil if the OperationInfo is valid.
func ValidateTriggerInfo ¶
func ValidateTriggerInfo(info *TriggerInfo) error
ValidateTriggerInfo validates the provided TriggerInfo object. It checks if the info is not nil and if the name and description fields are not empty.
Types ¶
type ConnectorCategory ¶
type ConnectorCategory string
const ( Apps ConnectorCategory = "apps" Core ConnectorCategory = "core" AI ConnectorCategory = "ai" Scripts ConnectorCategory = "scripts" Tools ConnectorCategory = "tools" )
func ConnectorCategoryFromString ¶
func ConnectorCategoryFromString(raw string) (ConnectorCategory, bool)
ConnectorCategoryFromString determines the enum value with an exact case match.
func ConnectorCategoryFromStringIgnoreCase ¶
func ConnectorCategoryFromStringIgnoreCase(raw string) (ConnectorCategory, bool)
ConnectorCategoryFromStringIgnoreCase determines the enum value with a case-insensitive match.
func (ConnectorCategory) IsValid ¶
func (_j ConnectorCategory) IsValid() bool
IsValid tests whether the value is a valid enum value.
func (ConnectorCategory) MarshalBinary ¶
func (_j ConnectorCategory) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface for ConnectorCategory.
func (ConnectorCategory) MarshalGQL ¶
func (_j ConnectorCategory) MarshalGQL(w io.Writer)
MarshalGQL implements the graphql.Marshaler interface for ConnectorCategory.
func (ConnectorCategory) MarshalJSON ¶
func (_j ConnectorCategory) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for ConnectorCategory.
func (ConnectorCategory) MarshalText ¶
func (_j ConnectorCategory) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for ConnectorCategory.
func (ConnectorCategory) MarshalYAML ¶
func (_j ConnectorCategory) MarshalYAML() (interface{}, error)
MarshalYAML implements a YAML Marshaler for ConnectorCategory.
func (ConnectorCategory) SQLTypeName ¶
func (ConnectorCategory) SQLTypeName() string
func (*ConnectorCategory) Scan ¶
func (_j *ConnectorCategory) Scan(value interface{}) error
Scan implements the sql/driver.Scanner interface for ConnectorCategory.
func (ConnectorCategory) String ¶
func (_j ConnectorCategory) String() string
String returns the string of the enum value. If the enum value is invalid, it will produce a string of the following pattern ConnectorCategory(%d) instead.
func (*ConnectorCategory) UnmarshalBinary ¶
func (_j *ConnectorCategory) UnmarshalBinary(text []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for ConnectorCategory.
func (*ConnectorCategory) UnmarshalGQL ¶
func (_j *ConnectorCategory) UnmarshalGQL(value interface{}) error
UnmarshalGQL implements the graphql.Unmarshaler interface for ConnectorCategory.
func (*ConnectorCategory) UnmarshalJSON ¶
func (_j *ConnectorCategory) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for ConnectorCategory.
func (*ConnectorCategory) UnmarshalText ¶
func (_j *ConnectorCategory) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for ConnectorCategory.
func (*ConnectorCategory) UnmarshalYAML ¶
func (_j *ConnectorCategory) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements a YAML Unmarshaler for ConnectorCategory.
func (ConnectorCategory) Validate ¶
func (_j ConnectorCategory) Validate() error
Validate whether the value is within the range of enum values.
func (ConnectorCategory) Values ¶
func (ConnectorCategory) Values() []string
Values returns a slice of all String values of the enum.
type ConnectorMetadata ¶
type ConnectorMetadata struct { Name string DisplayName string Description string Version string Authors []string Category ConnectorCategory Logo string }
ConnectorMetadata represents the metadata of a connector. It includes information such as the name, display name, description, version, authors, category, and logo of the connector.
type ConnectorPlugin ¶
type ConnectorPlugin struct { CreateArgs *CreateConnectorArgs VersionMetadata *sdkcore.ConnectorVersionMetadata Metadata *ConnectorMetadata Triggers map[string]ITrigger Operations map[string]IOperation TriggerMetadata map[string]*sdkcore.Trigger OperationsMetadata map[string]*sdkcore.Operation HasTrigger bool }
ConnectorPlugin represents a plugin that connects to a service or application. It contains information about the plugin's creation arguments, version metadata, connector metadata, triggers, operations, trigger metadata, and operations metadata.
func CreateConnector ¶
func CreateConnector(args *CreateConnectorArgs) (*ConnectorPlugin, error)
func NewConnectorPlugin ¶
func NewConnectorPlugin(args *CreateConnectorArgs) (*ConnectorPlugin, error)
NewConnectorPlugin creates a new ConnectorPlugin based on the provided CreateConnectorArgs. It validates the connector information and creates maps for triggers and operations. It also generates unique slugs for trigger and operation names. Finally, it creates the ConnectorMetadata and returns the ConnectorPlugin.
func (*ConnectorPlugin) Authenticate ¶
func (plugin *ConnectorPlugin) Authenticate(ctx context.Context)
Authenticate authenticates the connector plugin. It takes a context as an argument and does not return anything. Example usage:
ctx := context.Background() plugin.Authenticate(ctx)
func (*ConnectorPlugin) Test ¶
func (plugin *ConnectorPlugin) Test(ctx context.Context)
Test is a method of the ConnectorPlugin struct that is used to test the connectivity of the connector. It takes a context.Context as a parameter.
type CreateConnectorArgs ¶
type CreateConnectorArgs struct { Name string Description string Version string Logo string Category ConnectorCategory Triggers []ITrigger Operations []IOperation Authors []string }
type CreateIOperationArgs ¶
type CreateIOperationArgs struct { Name string Description string Input *map[string]interface{} Output *map[string]interface{} Run *func(ctx context.Context) (JSON, error) Auth *func(ctx context.Context) (JSON, error) Test *func(ctx context.Context) (JSON, error) GenerateSampleData *func(ctx context.Context) (JSON, error) }
CreateIOperationArgs represents the arguments for creating an IOperation. It contains the following fields: - Name: the name of the IOperation - Description: the description of the IOperation - Input
type CreateTriggerArgs ¶
type CreateTriggerArgs struct { Name string Description string Input *map[string]interface{} Output *map[string]interface{} Run *func(ctx context.Context) (JSON, error) Auth *func(ctx context.Context) (JSON, error) Test *func(ctx context.Context) (JSON, error) GenerateSampleData *func(ctx context.Context) (JSON, error) }
type IConnectorPlugin ¶
IConnectorPlugin is an interface that defines the methods for a connector plugin implementation. It provides functionality for authentication and testing.
type IOperation ¶
type IOperation interface { IRunnable GetInfo() *OperationInfo }
IOperation is an interface that represents an operation within a connector. It extends the IRunnable interface and provides a method to get information about the operation. GetInfo returns the OperationInfo metadata for the operation.
type IOperation interface { IRunnable GetInfo() *OperationInfo
type IRunnable ¶
type IRunnable interface { // Run executes the runnable entity with the provided context and run context, and returns the result as a JSON object or an error. Run(ctx *RunContext) (JSON, error) // Test runs a test of the runnable entity with the provided context, and returns the result as a JSON object or an error. Test(ctx *RunContext) (JSON, error) }
IRunnable is an interface that represents a runnable entity. Run executes the runnable entity with the provided context and run context, and returns the result as a JSON object or an error. Test runs a test of the runnable entity with the provided context, and returns the result as a JSON object or an error.
type ITrigger ¶
type ITrigger interface { IRunnable GetInfo() *TriggerInfo OnEnabled(ctx *RunContext) error OnDisabled(ctx *RunContext) error }
type OperationInfo ¶
type OperationInfo struct { // Key holds the value of the "key" field. Name string `json:"name,omitempty"` // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Input holds the value of the "input" field. Input map[string]*sdkcore.AutoFormSchema `json:"input,omitempty"` // Auth holds the value of the "auth" field. Auth *sdkcore.AutoFormSchema `json:"auth"` SampleOutput sdkcore.JSONObject `json:"sample_output"` ErrorSettings sdkcore.StepErrorSettings `json:"error_settings"` RequireAuth bool `json:"require_auth"` }
type PauseMetadata ¶
type PauseMetadata struct { Type sdkcore.PauseType `json:"type"` ResumeAt *time.Time `json:"resumeAt"` RequestID *string `json:"requestId"` Response *any `json:"response"` }
PauseMetadata represents metadata for pausing execution.
Type represents the type of pause, which can be either "DELAY" or "WEBHOOK". ResumeAt is an optional field that represents the time at which the execution should resume. RequestID is an optional field that represents the ID of the request associated with the pause. Response is an optional field that represents the response associated with the pause.
Example usage:
metadata := PauseMetadata{ Type: sdkcore.PauseType("DELAY"), ResumeAt: &time.Time{}, RequestID: &"requestID", Response: &any{}, }
PauseMetadataFull is an example usage of PauseMetadata:
type PauseMetadataFull struct { PauseMetadata }
RunContext.PauseExecution is a method that accepts PauseMetadata as a parameter:
func (rctx *RunContext) PauseExecution(metadata PauseMetadata) (JSON, error) { rctx.isPaused = true rctx.pausedTime = metadata.ResumeAt return &PauseMetadataFull{ PauseMetadata: metadata, }, nil }
The RunContext structure has a method PauseExecution that accepts PauseMetadata and pauses the execution based on the metadata provided:
type RunContext struct { Step *sdkcore.ConnectorStep `json:"step"` Auth *sdkcore.AuthContext `json:"auth"` State *sdkcore.StepsState `json:"state"` Workflow *sdkcore.WorkflowRunMetadata `json:"workflow"` Input sdkcore.JSONObject `json:"input"` ResolvedInput any `json:"resolvedInput"` LastRun *time.Time `json:"lastRun"` Files sdkcore.FileManager ctx context.Context ExecutionType sdkcore.ExecutionType `json:"executionType"` TriggerType sdkcore.TriggerHookType isPaused bool pausedTime *time.Time }
JSON is an alias for any: type JSON = any
sdkcore.PauseType is a type that represents the pause type and has the following methods: - SQLTypeName() string - Values() []string - IsValid() bool - Validate() error - String() string - MarshalBinary() ([]byte, error) - UnmarshalBinary(text []byte) error - MarshalGQL(w io.Writer) - UnmarshalGQL(value interface{}) error - MarshalJSON() ([]byte, error) - UnmarshalJSON(data []byte) error - Scan(value interface{}) error - MarshalText() ([]byte, error) - UnmarshalText(text []byte) error - MarshalYAML() (interface{}, error) - UnmarshalYAML(unmarshal func(interface{}) error) error
type PauseMetadataFull ¶
type PauseMetadataFull struct {
PauseMetadata
}
PauseMetadataFull is a type that extends the PauseMetadata struct. PauseMetadata is a struct that contains information about a pause execution, including the pause type, resume time, request ID, and response.
type PauseMetadata struct { Type sdkcore.PauseType `json:"type"` ResumeAt *time.Time `json:"resumeAt"` RequestID *string `json:"requestId"` Response *any `json:"response"` }
PauseMetadataFull extends the PauseMetadata struct.
type PauseMetadataFull struct { PauseMetadata }
This type is used in the RunContext.PauseExecution method to represent the metadata of a pause execution. Usage example:
func (rctx *RunContext) PauseExecution(metadata PauseMetadata) (JSON, error) { rctx.isPaused = true rctx.pausedTime = metadata.ResumeAt return &PauseMetadataFull{ PauseMetadata: metadata, }, nil }
type RunContext ¶
type RunContext struct { Auth *sdkcore.AuthContext `json:"auth"` Metadata *sdkcore.WorkflowRunMetadata `json:"metadata"` Input map[string]any `json:"input"` Files sdkcore.FileManager ExecutionType sdkcore.ExecutionType `json:"executionType"` Log *sdkcore.Log // contains filtered or unexported fields }
RunContext represents the context in which a workflow step is executed.
It contains information about the workflow, the current step, the connector version, the workflow instance, authentication data, and the state of the workflow steps.
func NewRunContext ¶ added in v0.2.7
func NewRunContext( ctx context.Context, step *sdkcore.ConnectorStep, state *sdkcore.StepRunData, workflow *sdkcore.WorkflowVersion, auth *sdkcore.AuthContext, runMode bool, ) *RunContext
func (*RunContext) GetPauseTime ¶
func (rctx *RunContext) GetPauseTime() *time.Time
GetPauseTime returns the paused time in the RunContext. It retrieves the value from the pausedTime field in the RunContext struct.
func (*RunContext) GetRawInput ¶ added in v0.2.7
func (rctx *RunContext) GetRawInput() sdkcore.JSONObject
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 (*RunContext) IsPaused ¶
func (rctx *RunContext) 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 (*RunContext) PauseExecution ¶
func (rctx *RunContext) PauseExecution(metadata PauseMetadata) (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.
func (*RunContext) SetContext ¶
func (rctx *RunContext) SetContext(ctx context.Context)
type SpiderTestRuntime ¶
type SpiderTestRuntime struct {
// contains filtered or unexported fields
}
func NewSpiderTest ¶
func NewSpiderTest(t *testing.T, instance *ConnectorPlugin) *SpiderTestRuntime
func (*SpiderTestRuntime) Close ¶
func (s *SpiderTestRuntime) Close() error
func (*SpiderTestRuntime) GetConfig ¶
func (s *SpiderTestRuntime) GetConfig() *ConnectorMetadata
func (*SpiderTestRuntime) OperationConfig ¶
func (s *SpiderTestRuntime) OperationConfig(name string) *sdkcore.Operation
func (*SpiderTestRuntime) Operations ¶
func (s *SpiderTestRuntime) Operations() []*sdkcore.Operation
func (*SpiderTestRuntime) RunAuth ¶
func (s *SpiderTestRuntime) RunAuth() error
func (*SpiderTestRuntime) RunOperation ¶
func (s *SpiderTestRuntime) RunOperation(name string, run *RunContext) (JSON, error)
func (*SpiderTestRuntime) RunTrigger ¶
func (s *SpiderTestRuntime) RunTrigger(name string, run *RunContext) (JSON, error)
func (*SpiderTestRuntime) TriggerConfig ¶
func (s *SpiderTestRuntime) TriggerConfig(name string) *sdkcore.Trigger
func (*SpiderTestRuntime) Triggers ¶
func (s *SpiderTestRuntime) Triggers() []*sdkcore.Trigger
type TriggerInfo ¶
type TriggerInfo struct { // Key holds the value of the "key" field. Name string `json:"name,omitempty" validate:"required"` // Type holds the value of the "description" field. Type sdkcore.TriggerType `json:"type,omitempty" validate:"required,oneof=SCHEDULED EVENT PUBSUB MANUAL WEBHOOK CRON"` // Description holds the value of the "description" field. Description string `json:"description,omitempty" validate:"required"` // Input holds the value of the "input" field. Input map[string]*sdkcore.AutoFormSchema `json:"input,omitempty"` // Auth holds the value of the "auth" field. Auth *sdkcore.AutoFormSchema `json:"auth"` SampleOutput sdkcore.JSONObject `json:"sample_output"` Settings *sdkcore.TriggerSettings `json:"settings" validate:"required"` ErrorSettings *sdkcore.StepErrorSettings `json:"error_settings" validate:"required"` RequireAuth bool `json:"requireAuth"` }
TriggerInfo represents the information of a trigger. It includes the name, description, input schema, authentication schema, sample output, error settings, and whether authentication is required.
type TriggerRunContext ¶
type TriggerRunContext struct { Metadata *sdkcore.WorkflowRunMetadata `json:"metadata"` Auth *sdkcore.AuthContext `json:"auth"` Trigger *sdkcore.Trigger }
TriggerRunContext is a struct that represents the context for triggering a run.