base

package
v0.10.0-beta Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 17 Imported by: 0

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 TrimBase64Mime

func TrimBase64Mime(b64 string) string

Types

type Component

type Component struct {
	Name string

	// Logger
	Logger *zap.Logger
	// contains filtered or unexported fields
}

Component is the basic component struct

func (*Component) GetTaskInputSchemas

func (comp *Component) GetTaskInputSchemas() map[string]string

GetTaskInputSchemas returns the task input schemas

func (*Component) GetTaskOutputSchemas

func (comp *Component) GetTaskOutputSchemas() map[string]string

GetTaskOutputSchemas returns the task output schemas

type Connector

type Connector struct {
	Component
	// contains filtered or unexported fields
}

Connector is the base struct for all connectors

func (*Connector) AddConnectorDefinition

func (c *Connector) AddConnectorDefinition(def *pipelinePB.ConnectorDefinition) error

AddConnectorDefinition adds a connector definition to the connector

func (*Connector) GetConnectorDefinitionByID

func (c *Connector) GetConnectorDefinitionByID(defID string, resourceConfig *structpb.Struct, componentConfig *structpb.Struct) (*pipelinePB.ConnectorDefinition, error)

GetConnectorDefinitionByID gets the connector definition by definition id

func (*Connector) GetConnectorDefinitionByUID

func (c *Connector) GetConnectorDefinitionByUID(defUID uuid.UUID, resourceConfig *structpb.Struct, componentConfig *structpb.Struct) (*pipelinePB.ConnectorDefinition, error)

GetConnectorDefinitionByUID gets the connector definition by definition uid

func (*Connector) IsCredentialField

func (c *Connector) IsCredentialField(defID string, target string) bool

IsCredentialField checks if the target field is credential field

func (*Connector) ListConnectorDefinitions

func (c *Connector) ListConnectorDefinitions() []*pipelinePB.ConnectorDefinition

ListConnectorDefinitions lists all the connector definitions

func (*Connector) ListCredentialField

func (c *Connector) ListCredentialField(defID string) ([]string, error)

ListCredentialField lists the credential fields by definition id

func (*Connector) LoadConnectorDefinitions

func (c *Connector) LoadConnectorDefinitions(definitionsJSONBytes []byte, tasksJSONBytes []byte, additionalJSONBytes map[string][]byte) error

LoadConnectorDefinitions loads the connector definitions from json files

type Execution

type Execution struct {
	Logger             *zap.Logger
	Component          IComponent
	ComponentExecution IExecution
	UID                uuid.UUID
	Config             *structpb.Struct
	Task               string
}

Execution is the base struct for all executions

func CreateExecutionHelper

func CreateExecutionHelper(e IExecution, comp IComponent, defUID uuid.UUID, task string, config *structpb.Struct, logger *zap.Logger) Execution

CreateExecutionHelper creates a new execution

func (*Execution) ExecuteWithValidation

func (e *Execution) ExecuteWithValidation(inputs []*structpb.Struct) ([]*structpb.Struct, error)

ExecuteWithValidation executes the execution with validation

func (*Execution) GetConfig

func (e *Execution) GetConfig() *structpb.Struct

GetConfig returns the config of the execution

func (*Execution) GetTask

func (e *Execution) GetTask() string

GetTask returns the task of the execution

func (*Execution) GetUID

func (e *Execution) GetUID() uuid.UUID

GetUID returns the uid of the execution

func (*Execution) Validate

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

Validate the input and output format

type IComponent

type IComponent interface {

	// Create a execution by definition uid and component configuration
	CreateExecution(defUID uuid.UUID, task string, config *structpb.Struct, logger *zap.Logger) (IExecution, error)

	// Get task input schemas
	GetTaskInputSchemas() map[string]string
	// Get task output schemas
	GetTaskOutputSchemas() map[string]string
	// contains filtered or unexported methods
}

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

type IConnector

type IConnector interface {
	IComponent

	// Functions that need to be implemented for all connectors
	// Test connection
	Test(defUID uuid.UUID, config *structpb.Struct, logger *zap.Logger) (pipelinePB.Connector_State, error)

	// Functions that shared for all connectors
	// Load connector definitions from json files
	LoadConnectorDefinitions(definitionsJSON []byte, tasksJSON []byte, additionalJSONBytes map[string][]byte) error
	// Add definition
	AddConnectorDefinition(def *pipelinePB.ConnectorDefinition) error
	// Get the connector definition by definition uid
	GetConnectorDefinitionByUID(defUID uuid.UUID, resourceConfig *structpb.Struct, componentConfig *structpb.Struct) (*pipelinePB.ConnectorDefinition, error)
	// Get the connector definition by definition id
	GetConnectorDefinitionByID(defID string, resourceConfig *structpb.Struct, componentConfig *structpb.Struct) (*pipelinePB.ConnectorDefinition, error)
	// Get the list of connector definitions under this connector
	ListConnectorDefinitions() []*pipelinePB.ConnectorDefinition

	// List the CredentialFields by definition id
	ListCredentialField(defID string) ([]string, error)
	// A helper function to check the target field a.b.c is credential
	IsCredentialField(defID string, target string) bool
}

IConnector is the interface that all connectors need to implement

type IExecution

type IExecution interface {
	// Functions that shared for all connectors
	// Validate the input and output format
	Validate(data []*structpb.Struct, jsonSchema string, target string) error

	// Execute
	GetTask() string
	GetConfig() *structpb.Struct
	GetUID() uuid.UUID

	// Execute
	ExecuteWithValidation(inputs []*structpb.Struct) ([]*structpb.Struct, error)
	// execute
	Execute(inputs []*structpb.Struct) ([]*structpb.Struct, error)
}

IExecution is the interface that all executions need to implement

type IOperator

type IOperator interface {
	IComponent

	// Functions that shared for all operators
	// Load operator definitions from json files, the additionalJSONBytes is only needed when you reference in-memory json file
	LoadOperatorDefinitions(definitionsJSON []byte, tasksJSON []byte, additionalJSONBytes map[string][]byte) error
	// Add definition
	AddOperatorDefinition(def *pipelinePB.OperatorDefinition) error
	// Get the operator definition by definition uid
	GetOperatorDefinitionByUID(defUID uuid.UUID, componentConfig *structpb.Struct) (*pipelinePB.OperatorDefinition, error)
	// Get the operator definition by definition id
	GetOperatorDefinitionByID(defID string, componentConfig *structpb.Struct) (*pipelinePB.OperatorDefinition, error)
	// Get the list of operator definitions under this operator
	ListOperatorDefinitions() []*pipelinePB.OperatorDefinition
}

IOperator is the interface that all operators need to implement

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 Operator

type Operator struct {
	Component
}

Operator is the base struct for all operators

func (*Operator) AddOperatorDefinition

func (o *Operator) AddOperatorDefinition(def *pipelinePB.OperatorDefinition) error

AddOperatorDefinition adds a operator definition to the operator

func (*Operator) GetOperatorDefinitionByID

func (o *Operator) GetOperatorDefinitionByID(defID string, componentConfig *structpb.Struct) (*pipelinePB.OperatorDefinition, error)

GetOperatorDefinitionByID returns the operator definition by definition id

func (*Operator) GetOperatorDefinitionByUID

func (o *Operator) GetOperatorDefinitionByUID(defUID uuid.UUID, componentConfig *structpb.Struct) (*pipelinePB.OperatorDefinition, error)

GetOperatorDefinitionByUID returns the operator definition by definition uid

func (*Operator) ListOperatorDefinitions

func (o *Operator) ListOperatorDefinitions() []*pipelinePB.OperatorDefinition

ListOperatorDefinitions returns the list of operator definitions under this operator

func (*Operator) LoadOperatorDefinitions

func (o *Operator) LoadOperatorDefinitions(definitionsJSONBytes []byte, tasksJSONBytes []byte, additionalJSONBytes map[string][]byte) error

LoadOperatorDefinitions loads the operator definitions from json files

Jump to

Keyboard shortcuts

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