js

package
v0.22.4 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: Apache-2.0 Imports: 22 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupScriptlet

func CleanupScriptlet(scriptlet string) string

func GetScriptlet

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

func GetScriptletNamesInSection added in v0.15.0

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

func GetScriptletsMetadata added in v0.15.0

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

func GetScriptletsMetadataSection added in v0.15.0

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

func IsScriptletNotFoundError added in v0.15.0

func IsScriptletNotFoundError(err error) bool

func SetScriptlet

func SetScriptlet(name string, scriptlet string, clout *cloutpkg.Clout) 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 []any) (any, error)

func (*CloutAPI) CallAll added in v0.19.0

func (self *CloutAPI) CallAll(function goja.FunctionCall) goja.Value

TODO: unused?

func (*CloutAPI) Coerce

func (self *CloutAPI) Coerce(value any) (any, error)

func (*CloutAPI) Define added in v0.14.0

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

func (*CloutAPI) Load added in v0.18.0

func (self *CloutAPI) Load(context contextpkg.Context, data any, forceFormat string) (*CloutAPI, error)

func (*CloutAPI) MarshalCBOR added in v0.18.0

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

(cbor.Marshaler interface)

func (*CloutAPI) MarshalJSON

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

(json.Marshaler interface)

func (*CloutAPI) MarshalMsgpack added in v0.21.0

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

(msgpack.Marshaler interface)

func (*CloutAPI) MarshalYAML

func (self *CloutAPI) MarshalYAML() (any, error)

([yaml.Marshaler] interface)

func (*CloutAPI) NewCoercible

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

func (*CloutAPI) NewKey

func (self *CloutAPI) NewKey() string

func (*CloutAPI) NewValidators added in v0.21.0

func (self *CloutAPI) NewValidators(value goja.Value, site any, source any, target any) (Validators, error)

func (*CloutAPI) Unwrap

func (self *CloutAPI) Unwrap(value any) any

type CloutContext

type CloutContext struct {
	Context   *Environment
	Clout     *cloutpkg.Clout
	JSContext *commonjs.Context
}

func (*CloutContext) NewExecutionContext added in v0.21.0

func (self *CloutContext) NewExecutionContext(site any, source any, target any) *ExecutionContext

type Coercible

type Coercible interface {
	Coerce() (ard.Value, error)
	AddValidators(Validators)
	Unwrap() ard.Value
}

type Environment added in v0.22.4

type Environment struct {
	Arguments     map[string]string
	Quiet         bool
	Format        string
	Strict        bool
	Pretty        bool
	Base64        bool
	FilePath      string
	Log           commonlog.Logger
	Stdout        io.Writer
	Stderr        io.Writer
	Stdin         io.Writer
	StdoutStylist *terminal.Stylist
	URLContext    *exturl.Context
	// contains filtered or unexported fields
}

func NewEnvironment added in v0.22.4

func NewEnvironment(name string, log commonlog.Logger, arguments map[string]string, quiet bool, format string, strict bool, pretty bool, base64 bool, filePath string, urlContext *exturl.Context) *Environment

func (*Environment) CreateCloutExtension added in v0.22.4

func (self *Environment) CreateCloutExtension(clout *cloutpkg.Clout) commonjs.CreateExtensionFunc

func (*Environment) CreateTranscribeExtension added in v0.22.4

func (self *Environment) CreateTranscribeExtension(jsContext *commonjs.Context) any

(commonjs.CreateExtensionFunc signature)

func (*Environment) NewCloutAPI added in v0.22.4

func (self *Environment) NewCloutAPI(clout *cloutpkg.Clout, jsContext *commonjs.Context) *CloutAPI

func (*Environment) NewCloutContext added in v0.22.4

func (self *Environment) NewCloutContext(clout *cloutpkg.Clout, jsContext *commonjs.Context) *CloutContext

func (*Environment) NewJsEnvironment added in v0.22.4

func (self *Environment) NewJsEnvironment(clout *cloutpkg.Clout, extensions map[string]commonjs.CreateExtensionFunc) *commonjs.Environment

func (*Environment) NewTranscribeAPI added in v0.22.4

func (self *Environment) NewTranscribeAPI() *TranscribeAPI

func (*Environment) Require added in v0.22.4

func (self *Environment) Require(clout *cloutpkg.Clout, scriptletName string, extensions map[string]commonjs.CreateExtensionFunc) (*goja.Object, error)

type Error

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

func (*Error) Error

func (self *Error) Error() string

(error interface)

func (*Error) Problem

func (self *Error) Problem(stylist *terminal.Stylist) (string, 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 ExecContext added in v0.22.3

type ExecContext struct {
	Clout      *cloutpkg.Clout
	Problems   *problemspkg.Problems
	URLContext *exturl.Context
	History    bool
	Format     string
	Strict     bool
	Pretty     bool
	Base64     bool
}

func (*ExecContext) Coerce added in v0.22.3

func (self *ExecContext) Coerce()

func (*ExecContext) Exec added in v0.22.3

func (self *ExecContext) Exec(scriptletName string, arguments map[string]string) *goja.Object

func (*ExecContext) ExecWithHistory added in v0.22.3

func (self *ExecContext) ExecWithHistory(scriptletName string) *goja.Object

func (*ExecContext) NewEnvironment added in v0.22.4

func (self *ExecContext) NewEnvironment(scriptletName string, arguments map[string]string) *Environment

func (*ExecContext) Outputs added in v0.22.3

func (self *ExecContext) Outputs() *goja.Object

func (*ExecContext) Resolve added in v0.22.3

func (self *ExecContext) Resolve()

type ExecutionContext added in v0.21.0

type ExecutionContext struct {
	CloutContext *CloutContext
	Site         any
	Source       any
	Target       any
}

func (*ExecutionContext) Call added in v0.21.0

func (self *ExecutionContext) Call(scriptletName string, functionName string, arguments ...any) (any, error)

func (*ExecutionContext) NewCoercible added in v0.21.0

func (self *ExecutionContext) NewCoercible(data ard.Value, meta ard.StringMap) (Coercible, error)

func (*ExecutionContext) NewConverter added in v0.21.0

func (self *ExecutionContext) NewConverter(meta ard.StringMap) (*FunctionCall, error)

func (*ExecutionContext) NewFunctionCall added in v0.21.0

func (self *ExecutionContext) NewFunctionCall(map_ ard.StringMap, notation ard.StringMap, meta ard.StringMap) (*FunctionCall, error)

func (*ExecutionContext) NewList added in v0.21.0

func (self *ExecutionContext) NewList(list ard.List, elementMeta ard.StringMap) (List, error)

func (*ExecutionContext) NewListValue added in v0.21.0

func (self *ExecutionContext) NewListValue(list ard.List, notation ard.StringMap, meta ard.StringMap) (*Value, error)

func (*ExecutionContext) NewMap added in v0.21.0

func (self *ExecutionContext) NewMap(list ard.List, keyMeta ard.StringMap, valueMeta ard.StringMap, fieldsMeta ard.StringMap) (Map, error)

func (*ExecutionContext) NewMapEntry added in v0.21.0

func (self *ExecutionContext) NewMapEntry(data any, keyMeta ard.StringMap, valueMeta ard.StringMap, fieldsMeta ard.StringMap) (MapEntry, error)

func (*ExecutionContext) NewMapValue added in v0.21.0

func (self *ExecutionContext) NewMapValue(list ard.List, notation ard.StringMap, meta ard.StringMap) (*Value, error)

func (*ExecutionContext) NewValidators added in v0.21.0

func (self *ExecutionContext) NewValidators(list ard.List, meta ard.StringMap) (Validators, error)

func (*ExecutionContext) NewValidatorsFromMeta added in v0.21.0

func (self *ExecutionContext) NewValidatorsFromMeta(meta ard.StringMap) (Validators, error)

func (*ExecutionContext) NewValue added in v0.21.0

func (self *ExecutionContext) NewValue(data ard.Value, notation ard.StringMap, meta ard.StringMap) (*Value, error)

type FunctionCall

type FunctionCall struct {
	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"`
	Validators Validators    `json:"validators,omitempty" yaml:"validators,omitempty"`
	Converter  *FunctionCall `json:"converter,omitempty" yaml:"converter,omitempty"`

	Notation         ard.StringMap     `json:"-" yaml:"-"`
	ExecutionContext *ExecutionContext `json:"-" yaml:"-"`
}

func (*FunctionCall) AddValidators added in v0.21.0

func (self *FunctionCall) AddValidators(validators Validators)

(Coercible interface)

func (*FunctionCall) Coerce

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

(Coercible interface)

func (*FunctionCall) CoerceArguments

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

func (*FunctionCall) Convert added in v0.19.0

func (self *FunctionCall) Convert(value ard.Value) (ard.Value, error)

func (*FunctionCall) NewError

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

func (*FunctionCall) NewErrorf

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

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 []any, err error) *Error

type List

type List []Coercible

func (List) Coerce

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

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, any, error)

type ScriptletNotFoundError added in v0.15.0

type ScriptletNotFoundError struct {
	// contains filtered or unexported fields
}

func NewScriptletNotFoundError added in v0.15.0

func NewScriptletNotFoundError(format string, args ...any) *ScriptletNotFoundError

func (*ScriptletNotFoundError) Error added in v0.15.0

func (self *ScriptletNotFoundError) Error() string

(error interface)

type TranscribeAPI added in v0.22.4

type TranscribeAPI struct {
	*api.Transcribe

	Stdout        io.Writer
	Stderr        io.Writer
	Stdin         io.Writer
	StdoutStylist *terminal.Stylist
	FilePath      string
	Format        string
	Strict        bool
	Pretty        bool
	Base64        bool
	// contains filtered or unexported fields
}

func (*TranscribeAPI) Output added in v0.22.4

func (self *TranscribeAPI) Output(data any, path string, dontOverwrite bool) error

type Validators added in v0.21.0

type Validators []*FunctionCall

func (Validators) Apply added in v0.21.0

func (self Validators) Apply(value any) error

func (Validators) IsValid added in v0.21.0

func (self Validators) IsValid(value any) (bool, error)

Called from JavaScript

type Value

type Value struct {
	Data       any           `json:"data" yaml:"data"` // List, Map, or ard.Value
	Validators Validators    `json:"validators,omitempty" yaml:"validators,omitempty"`
	Converter  *FunctionCall `json:"converter,omitempty" yaml:"converter,omitempty"`

	Notation ard.StringMap `json:"-" yaml:"-"`
}

func (*Value) AddValidators added in v0.21.0

func (self *Value) AddValidators(validators Validators)

(Coercible interface)

func (*Value) Coerce

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

(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