js

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: Apache-2.0 Imports: 23 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallFunction

func CallFunction(runtime *goja.Runtime, functionName string, arguments []interface{}) (interface{}, error)

func CleanupScriptlet

func CleanupScriptlet(scriptlet string) string

func GetMetadata

func GetMetadata(clout *cloutpkg.Clout) (ard.StringMap, error)

func GetMetadataSection

func GetMetadataSection(name string, clout *cloutpkg.Clout) (ard.Value, error)

func GetScriptlet

func GetScriptlet(name string, clout *cloutpkg.Clout) (string, error)

func GetScriptletNames added in v0.14.0

func GetScriptletNames(baseName string, clout *cloutpkg.Clout) ([]string, error)

func SetScriptlet

func SetScriptlet(name string, scriptlet string, clout *cloutpkg.Clout) error

func ToJavaScriptStyle

func ToJavaScriptStyle(name string) string

func UnwrapException

func UnwrapException(err error) error

Types

type CloutAPI

type CloutAPI struct {
	*cloutpkg.Clout
	// contains filtered or unexported fields
}

func (*CloutAPI) Call

func (self *CloutAPI) Call(scriptletName string, functionName string, arguments []interface{}) (interface{}, error)

func (*CloutAPI) Coerce

func (self *CloutAPI) Coerce(value interface{}) (interface{}, error)

func (*CloutAPI) Define added in v0.14.0

func (self *CloutAPI) Define(scriptletName string, scriptlet string) error

func (*CloutAPI) Exec

func (self *CloutAPI) Exec(scriptletName string) error

func (*CloutAPI) ExecAll added in v0.14.0

func (self *CloutAPI) ExecAll(scriptletBaseName string) error

func (*CloutAPI) MarshalJSON

func (self *CloutAPI) MarshalJSON() ([]byte, error)

json.Marshaler interface

func (*CloutAPI) MarshalYAML

func (self *CloutAPI) MarshalYAML() (interface{}, error)

yaml.Marshaler interface

func (*CloutAPI) NewCoercible

func (self *CloutAPI) NewCoercible(value goja.Value, site interface{}, source interface{}, target interface{}) (Coercible, error)

func (*CloutAPI) NewConstraints

func (self *CloutAPI) NewConstraints(value goja.Value, site interface{}, source interface{}, target interface{}) (Constraints, error)

func (*CloutAPI) NewKey

func (self *CloutAPI) NewKey() string

func (*CloutAPI) Unwrap

func (self *CloutAPI) Unwrap(value interface{}) interface{}

type CloutContext

type CloutContext struct {
	Context *Context
	Clout   *cloutpkg.Clout
	Runtime *goja.Runtime
}

func (*CloutContext) CallFunction

func (self *CloutContext) CallFunction(scriptletName string, functionName string, arguments []interface{}, functionCallContext FunctionCallContext) (interface{}, error)

func (*CloutContext) Exec

func (self *CloutContext) Exec(scriptletName string) error

func (*CloutContext) ExecAll added in v0.14.0

func (self *CloutContext) ExecAll(scriptletBaseName string) error

func (*CloutContext) NewCoercible

func (self *CloutContext) NewCoercible(data ard.Value, functionCallContext FunctionCallContext) (Coercible, error)

func (*CloutContext) NewConstraints

func (self *CloutContext) NewConstraints(list ard.List, functionCallContext FunctionCallContext) (Constraints, error)

func (*CloutContext) NewConstraintsFromNotation

func (self *CloutContext) NewConstraintsFromNotation(notation ard.StringMap, name string, functionCallContext FunctionCallContext) (Constraints, error)

func (*CloutContext) NewFunctionCall

func (self *CloutContext) NewFunctionCall(map_ ard.StringMap, notation ard.StringMap, functionCallContext FunctionCallContext) (*FunctionCall, error)

func (*CloutContext) NewList

func (self *CloutContext) NewList(list ard.List, entryConstraints Constraints, functionCallContext FunctionCallContext) (List, error)

func (*CloutContext) NewMap

func (self *CloutContext) NewMap(list ard.List, keyConstraints Constraints, valueConstraints Constraints, functionCallContext FunctionCallContext) (Map, error)

func (*CloutContext) NewMapEntry

func (self *CloutContext) NewMapEntry(data interface{}, keyConstraints Constraints, valueConstraints Constraints, functionCallContext FunctionCallContext) (MapEntry, error)

func (*CloutContext) NewRuntime

func (self *CloutContext) NewRuntime(apis map[string]interface{}) *goja.Runtime

func (*CloutContext) NewValue

func (self *CloutContext) NewValue(data ard.Value, notation ard.StringMap, functionCallContext FunctionCallContext) (*Value, error)

func (*CloutContext) NewValueForList

func (self *CloutContext) NewValueForList(list ard.List, notation ard.StringMap, functionCallContext FunctionCallContext) (*Value, error)

func (*CloutContext) NewValueForMap

func (self *CloutContext) NewValueForMap(list ard.List, notation ard.StringMap, functionCallContext FunctionCallContext) (*Value, error)

type Coercible

type Coercible interface {
	Coerce() (ard.Value, error)
	SetConstraints(Constraints)
	Unwrap() ard.Value
}

type Constraints

type Constraints []*FunctionCall

func (Constraints) Apply

func (self Constraints) Apply(value interface{}) (interface{}, error)

func (Constraints) Validate

func (self Constraints) Validate(value interface{}) (bool, error)

type Context

type Context struct {
	Quiet           bool
	Format          string
	Strict          bool
	AllowTimestamps bool
	Pretty          bool
	Output          string
	Log             *Log
	Stdout          io.Writer
	Stderr          io.Writer
	Stdin           io.Writer
	// contains filtered or unexported fields
}

func NewContext

func NewContext(name string, logger *logging.Logger, quiet bool, format string, strict bool, allowTimestamps bool, pretty bool, output string) *Context

func (*Context) Exec

func (self *Context) Exec(clout *cloutpkg.Clout, scriptletName string, apis map[string]interface{}) error

func (*Context) Fail added in v0.11.0

func (self *Context) Fail(message string)

func (*Context) FailOnError

func (self *Context) FailOnError(err error)

func (*Context) Failf

func (self *Context) Failf(format string, args ...interface{})

func (*Context) GetProgram

func (self *Context) GetProgram(name string, scriptlet string) (*goja.Program, error)

func (*Context) NewCloutAPI

func (self *Context) NewCloutAPI(clout *cloutpkg.Clout, runtime *goja.Runtime) *CloutAPI

func (*Context) NewCloutContext

func (self *Context) NewCloutContext(clout *cloutpkg.Clout, runtime *goja.Runtime) *CloutContext

func (*Context) NewCloutRuntime

func (self *Context) NewCloutRuntime(clout *cloutpkg.Clout, apis map[string]interface{}) *goja.Runtime

func (*Context) NewPucciniAPI

func (self *Context) NewPucciniAPI() *PucciniAPI

type Error

type Error struct {
	FunctionCall *FunctionCall
	Arguments    []interface{}
	Message      string
	Cause        error
}

func (*Error) Error

func (self *Error) Error() string

error interface

func (*Error) Problem

func (self *Error) Problem() (string, string, int, int)

problems.Problematic interface

func (*Error) Signature

func (self *Error) Signature() string

func (*Error) String

func (self *Error) String() string

fmt.Stringer interface

type FunctionCall

type FunctionCall struct {
	CloutContext        *CloutContext       `json:"-" yaml:"-"`
	FunctionCallContext FunctionCallContext `json:"-" yaml:"-"`
	Notation            ard.StringMap       `json:"-" yaml:"-"`

	Name        string      `json:"name" yaml:"name"`
	Arguments   []Coercible `json:"arguments" yaml:"arguments"`
	Path        string      `json:"path,omitempty" yaml:"path,omitempty"`
	URL         string      `json:"url,omitempty" yaml:"url,omitempty"`
	Row         int         `json:"row" yaml:"row"`
	Column      int         `json:"column" yaml:"column"`
	Constraints Constraints `json:"constraints,omitempty" yaml:"constraints,omitempty"`
}

func (*FunctionCall) Coerce

func (self *FunctionCall) Coerce() (ard.Value, error)

Coercible interface

func (*FunctionCall) CoerceArguments

func (self *FunctionCall) CoerceArguments() ([]ard.Value, error)

func (*FunctionCall) NewError

func (self *FunctionCall) NewError(arguments []interface{}, message string, cause error) *Error

func (*FunctionCall) NewErrorf

func (self *FunctionCall) NewErrorf(arguments []interface{}, format string, arg ...interface{}) *Error

func (*FunctionCall) SetConstraints

func (self *FunctionCall) SetConstraints(constraints Constraints)

Coercible interface

func (*FunctionCall) Signature

func (self *FunctionCall) Signature(arguments []ard.Value) string

func (*FunctionCall) Unwrap

func (self *FunctionCall) Unwrap() ard.Value

Coercible interface

func (*FunctionCall) Validate

func (self *FunctionCall) Validate(value ard.Value, errorWhenInvalid bool) (bool, error)

func (*FunctionCall) WrapError

func (self *FunctionCall) WrapError(arguments []interface{}, err error) *Error

type FunctionCallContext

type FunctionCallContext struct {
	Site   interface{}
	Source interface{}
	Target interface{}
}

func (FunctionCallContext) API

func (self FunctionCallContext) API() map[string]interface{}

type List

type List []Coercible

func (List) Coerce

func (self List) Coerce() (ard.Value, error)

type Log

type Log struct {
	Prefix string
	// contains filtered or unexported fields
}

func NewLog

func NewLog(logger *logging.Logger, name string) *Log

func (*Log) Debugf

func (self *Log) Debugf(f string, args ...interface{})

func (*Log) Errorf

func (self *Log) Errorf(f string, args ...interface{})

func (*Log) Infof

func (self *Log) Infof(f string, args ...interface{})

func (*Log) Noticef

func (self *Log) Noticef(f string, args ...interface{})

func (*Log) Warningf

func (self *Log) Warningf(f string, args ...interface{})

type Map

type Map []MapEntry

func (Map) Coerce

func (self Map) Coerce() (ard.Value, error)

type MapEntry

type MapEntry struct {
	Key   Coercible `json:"$key" yaml:"$key"`
	Value Coercible `json:"$value" yaml:"$value"`
}

func (MapEntry) Coerce

func (self MapEntry) Coerce() (string, interface{}, error)

type Mapper

type Mapper struct{}

func (Mapper) FieldName

func (self Mapper) FieldName(t reflect.Type, f reflect.StructField) string

goja.FieldNameMapper interface

func (Mapper) MethodName

func (self Mapper) MethodName(t reflect.Type, m reflect.Method) string

goja.FieldNameMapper interface

type PucciniAPI

type PucciniAPI struct {
	Log             *Log
	Stdout          io.Writer
	Stderr          io.Writer
	Stdin           io.Writer
	Output          string
	Format          string
	Strict          bool
	AllowTimestamps bool
	Pretty          bool
	// contains filtered or unexported fields
}

func (*PucciniAPI) Atob added in v0.14.0

func (self *PucciniAPI) Atob(from string) ([]byte, error)

func (*PucciniAPI) Btoa added in v0.14.0

func (self *PucciniAPI) Btoa(from []byte) (string, error)

func (*PucciniAPI) DeepCopy added in v0.14.0

func (self *PucciniAPI) DeepCopy(value ard.Value) ard.Value

func (*PucciniAPI) Download

func (self *PucciniAPI) Download(sourceUrl string, targetPath string) error

func (*PucciniAPI) Exec

func (self *PucciniAPI) Exec(name string, arguments ...string) (string, error)

func (*PucciniAPI) Fail added in v0.11.0

func (self *PucciniAPI) Fail(message string)

func (*PucciniAPI) Failf added in v0.11.0

func (self *PucciniAPI) Failf(format string, args ...interface{})

func (*PucciniAPI) IsType added in v0.14.0

func (entry *PucciniAPI) IsType(value ard.Value, type_ string) (bool, error)

func (*PucciniAPI) JoinFilePath

func (entry *PucciniAPI) JoinFilePath(elements ...string) string

func (*PucciniAPI) LoadString added in v0.14.0

func (self *PucciniAPI) LoadString(url string) (string, error)

func (*PucciniAPI) NewXMLDocument

func (self *PucciniAPI) NewXMLDocument() *etree.Document

func (*PucciniAPI) Sprintf

func (entry *PucciniAPI) Sprintf(format string, args ...interface{}) string

func (*PucciniAPI) Timestamp

func (self *PucciniAPI) Timestamp() ard.Value

func (*PucciniAPI) ValidateFormat

func (entry *PucciniAPI) ValidateFormat(code string, format string) error

func (*PucciniAPI) Write

func (self *PucciniAPI) Write(data interface{}, path string, dontOverwrite bool)

type Value

type Value struct {
	Notation ard.StringMap `json:"-" yaml:"-"`

	Data        interface{} `json:"data" yaml:"data"` // List, Map, or ard.Value
	Constraints Constraints `json:"constraints,omitempty" yaml:"constraints,omitempty"`
}

func (*Value) Coerce

func (self *Value) Coerce() (ard.Value, error)

Coercible interface

func (*Value) SetConstraints

func (self *Value) SetConstraints(constraints Constraints)

Coercible interface

func (*Value) Unwrap

func (self *Value) Unwrap() ard.Value

Coercible interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳