base

package
v0.15.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 17 Imported by: 41

Documentation

Index

Constants

View Source
const OpenAPITemplate = `` /* 1538-byte string literal not displayed */

Variables

View Source
var InstillAcceptFormatsMeta = jsonschema.MustCompileString("instillAcceptFormats.json", `{
	"properties" : {
		"instillAcceptFormats": {
			"type": "array",
			"items": {
				"type": "string"
			}
		}
	}
}`)
View Source
var InstillFormatMeta = jsonschema.MustCompileString("instillFormat.json", `{
	"properties" : {
		"instillFormat": {
			"type": "string"
		}
	}
}`)

Functions

func CompileInstillAcceptFormats

func CompileInstillAcceptFormats(sch *structpb.Struct) error

func CompileInstillFormat

func CompileInstillFormat(sch *structpb.Struct) error

func ConvertFromStructpb

func ConvertFromStructpb(from *structpb.Struct, to interface{}) error

ConvertFromStructpb converts from structpb.Struct to a struct

func ConvertToStructpb

func ConvertToStructpb(from interface{}) (*structpb.Struct, error)

ConvertToStructpb converts from a struct to structpb.Struct

func FormatErrors

func FormatErrors(inputPath string, e jsonschema.Detailed, errors *[]string)

func RenderJSON

func RenderJSON(tasksJSONBytes []byte, additionalJSONBytes map[string][]byte) ([]byte, error)

func TaskIDToTitle

func TaskIDToTitle(id string) string

TaskIDToTitle builds a Task title from its ID. This is used when the `title` key in the task definition isn't present.

func TrimBase64Mime

func TrimBase64Mime(b64 string) string

func Validate

func Validate(data []*structpb.Struct, jsonSchema string, target string) error

Validate the input and output format

Types

type BaseConnector

type BaseConnector struct {
	Logger       *zap.Logger
	UsageHandler UsageHandler
	// contains filtered or unexported fields
}

Connector is the base struct for all connectors

func (*BaseConnector) GetConnectorDefinition

func (c *BaseConnector) GetConnectorDefinition(sysVars map[string]any, component *pipelinePB.ConnectorComponent) (*pipelinePB.ConnectorDefinition, error)

func (*BaseConnector) GetID

func (c *BaseConnector) GetID() string

func (*BaseConnector) GetLogger

func (c *BaseConnector) GetLogger() *zap.Logger

func (*BaseConnector) GetTaskInputSchemas

func (c *BaseConnector) GetTaskInputSchemas() map[string]string

func (*BaseConnector) GetTaskOutputSchemas

func (c *BaseConnector) GetTaskOutputSchemas() map[string]string

func (*BaseConnector) GetUID

func (c *BaseConnector) GetUID() uuid.UUID

func (*BaseConnector) GetUsageHandler

func (c *BaseConnector) GetUsageHandler() UsageHandler

func (*BaseConnector) IsCredentialField

func (c *BaseConnector) IsCredentialField(target string) bool

IsCredentialField checks if the target field is credential field

func (*BaseConnector) ListCredentialField

func (c *BaseConnector) ListCredentialField() ([]string, error)

ListCredentialField lists the credential fields by definition id

func (*BaseConnector) LoadConnectorDefinition

func (c *BaseConnector) LoadConnectorDefinition(definitionJSONBytes []byte, tasksJSONBytes []byte, additionalJSONBytes map[string][]byte) error

LoadConnectorDefinition loads the connector definitions from json files

type BaseConnectorExecution

type BaseConnectorExecution struct {
	Connector       IConnector
	SystemVariables map[string]any
	Connection      *structpb.Struct
	Task            string
}

func (*BaseConnectorExecution) GetConnection

func (e *BaseConnectorExecution) GetConnection() *structpb.Struct

func (*BaseConnectorExecution) GetConnector

func (e *BaseConnectorExecution) GetConnector() IConnector

func (*BaseConnectorExecution) GetLogger

func (e *BaseConnectorExecution) GetLogger() *zap.Logger

func (*BaseConnectorExecution) GetSystemVariables

func (e *BaseConnectorExecution) GetSystemVariables() map[string]any

func (*BaseConnectorExecution) GetTask

func (e *BaseConnectorExecution) GetTask() string

func (*BaseConnectorExecution) GetTaskInputSchema

func (e *BaseConnectorExecution) GetTaskInputSchema() string

func (*BaseConnectorExecution) GetTaskOutputSchema

func (e *BaseConnectorExecution) GetTaskOutputSchema() string

func (*BaseConnectorExecution) GetUsageHandler

func (e *BaseConnectorExecution) GetUsageHandler() UsageHandler

type BaseOperator

type BaseOperator struct {
	Logger       *zap.Logger
	UsageHandler UsageHandler
	// contains filtered or unexported fields
}

func (*BaseOperator) GetID

func (o *BaseOperator) GetID() string

func (*BaseOperator) GetLogger

func (o *BaseOperator) GetLogger() *zap.Logger

func (*BaseOperator) GetOperatorDefinition

func (o *BaseOperator) GetOperatorDefinition(sysVars map[string]any, component *pipelinePB.OperatorComponent) (*pipelinePB.OperatorDefinition, error)

func (*BaseOperator) GetTaskInputSchemas

func (o *BaseOperator) GetTaskInputSchemas() map[string]string

func (*BaseOperator) GetTaskOutputSchemas

func (o *BaseOperator) GetTaskOutputSchemas() map[string]string

func (*BaseOperator) GetUID

func (o *BaseOperator) GetUID() uuid.UUID

func (*BaseOperator) GetUsageHandler

func (o *BaseOperator) GetUsageHandler() UsageHandler

func (*BaseOperator) LoadOperatorDefinition

func (o *BaseOperator) LoadOperatorDefinition(definitionJSONBytes []byte, tasksJSONBytes []byte, additionalJSONBytes map[string][]byte) error

LoadOperatorDefinition loads the operator definitions from json files

type BaseOperatorExecution

type BaseOperatorExecution struct {
	Operator        IOperator
	SystemVariables map[string]any
	Task            string
}

func (*BaseOperatorExecution) GetLogger

func (e *BaseOperatorExecution) GetLogger() *zap.Logger

func (*BaseOperatorExecution) GetOperator

func (e *BaseOperatorExecution) GetOperator() IOperator

func (*BaseOperatorExecution) GetSystemVariables

func (e *BaseOperatorExecution) GetSystemVariables() map[string]any

func (*BaseOperatorExecution) GetTask

func (e *BaseOperatorExecution) GetTask() string

func (*BaseOperatorExecution) GetTaskInputSchema

func (e *BaseOperatorExecution) GetTaskInputSchema() string

func (*BaseOperatorExecution) GetTaskOutputSchema

func (e *BaseOperatorExecution) GetTaskOutputSchema() string

func (*BaseOperatorExecution) GetUsageHandler

func (e *BaseOperatorExecution) GetUsageHandler() UsageHandler

type ExecutionWrapper

type ExecutionWrapper struct {
	Execution IExecution
}

func (*ExecutionWrapper) Execute

func (e *ExecutionWrapper) Execute(inputs []*structpb.Struct) ([]*structpb.Struct, error)

ExecuteWithValidation executes the execution with validation

type IComponent

type IComponent interface {
	GetID() string
	GetUID() uuid.UUID
	GetLogger() *zap.Logger
	GetUsageHandler() UsageHandler
	GetTaskInputSchemas() map[string]string
	GetTaskOutputSchemas() map[string]string
}

IComponent is the interface that wraps the basic component methods. All component need to implement this interface.

type IConnector

type IConnector interface {
	IComponent

	LoadConnectorDefinition(definitionJSON []byte, tasksJSON []byte, additionalJSONBytes map[string][]byte) error

	// Note: Some content in the definition JSON schema needs to be generated by sysVars or component setting.
	GetConnectorDefinition(sysVars map[string]any, component *pipelinePB.ConnectorComponent) (*pipelinePB.ConnectorDefinition, error)

	CreateExecution(sysVars map[string]any, connection *structpb.Struct, task string) (*ExecutionWrapper, error)
	Test(sysVars map[string]any, connection *structpb.Struct) error

	IsCredentialField(target string) bool
}

IConnector is the interface that all connectors need to implement

type IConnectorExecution

type IConnectorExecution interface {
	IExecution

	GetConnector() IConnector
	GetConnection() *structpb.Struct
}

type IExecution

type IExecution interface {
	GetTask() string
	GetLogger() *zap.Logger
	GetUsageHandler() UsageHandler
	GetTaskInputSchema() string
	GetTaskOutputSchema() string

	Execute([]*structpb.Struct) ([]*structpb.Struct, error)
}

type IOperator

type IOperator interface {
	IComponent

	LoadOperatorDefinition(definitionJSON []byte, tasksJSON []byte, additionalJSONBytes map[string][]byte) error

	// Note: Some content in the definition JSON schema needs to be generated by sysVars or component setting.
	GetOperatorDefinition(sysVars map[string]any, component *pipelinePB.OperatorComponent) (*pipelinePB.OperatorDefinition, error)

	CreateExecution(sysVars map[string]any, task string) (*ExecutionWrapper, error)
}

type IOperatorExecution

type IOperatorExecution interface {
	IExecution

	GetOperator() IOperator
}

type InstillAcceptFormatsCompiler

type InstillAcceptFormatsCompiler struct{}

func (InstillAcceptFormatsCompiler) Compile

func (InstillAcceptFormatsCompiler) Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error)

type InstillAcceptFormatsSchema

type InstillAcceptFormatsSchema []string

func (InstillAcceptFormatsSchema) Validate

func (s InstillAcceptFormatsSchema) Validate(ctx jsonschema.ValidationContext, v interface{}) error

type InstillFormatCompiler

type InstillFormatCompiler struct{}

func (InstillFormatCompiler) Compile

func (InstillFormatCompiler) Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error)

type InstillFormatSchema

type InstillFormatSchema string

func (InstillFormatSchema) Validate

func (s InstillFormatSchema) Validate(ctx jsonschema.ValidationContext, v interface{}) error

type UsageHandler

type UsageHandler interface {
	Check() error
	Collect() error
}

TODO: add parameters for usage check and collection

Jump to

Keyboard shortcuts

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