plugins

package
v0.0.0-...-75e7317 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Pools = &VMPools{
	pools: map[string]*VMPool{},
}

Functions

func CreateGoJaProgram

func CreateGoJaProgram(file string, script []byte) (program *goja.Program, content string, err error)

func ExtractInlineJsArrowFunc

func ExtractInlineJsArrowFunc(handlerContent, handlerName string) string

func ExtractInlineJsFunc

func ExtractInlineJsFunc(handlerContent, handlerName string) string

func ExtractInlineJsNormalFunc

func ExtractInlineJsNormalFunc(handlerContent, handlerName string) string

func IsValidJSFuncName

func IsValidJSFuncName(name string) bool

Types

type AppLike

type AppLike interface {
	fs.Hookable
	DB() db.Client
	Resources() *fs.ResourcesManager
	Config() *fs.Config
	Logger() logger.Logger
}

type Builder

type Builder struct {
	*db.QueryBuilder[*entity.Entity]
	// contains filtered or unexported fields
}

func (*Builder) Where

func (b *Builder) Where(predicates ...map[string]any) (*Builder, error)

type ConfigActions

type ConfigActions struct {
	*fs.Config `json:"config"`
	// contains filtered or unexported fields
}

func NewConfigActions

func NewConfigActions(app AppLike, program *Program, set map[string]any) *ConfigActions

func (*ConfigActions) AddSchemas

func (p *ConfigActions) AddSchemas(schemas ...map[string]any) error

func (*ConfigActions) OnPostDBCreate

func (p *ConfigActions) OnPostDBCreate(hooks ...goja.Value) error

func (*ConfigActions) OnPostDBDelete

func (p *ConfigActions) OnPostDBDelete(hooks ...goja.Value) error

func (*ConfigActions) OnPostDBExec

func (p *ConfigActions) OnPostDBExec(hooks ...goja.Value) error

func (*ConfigActions) OnPostDBQuery

func (p *ConfigActions) OnPostDBQuery(hooks ...goja.Value) error

func (*ConfigActions) OnPostDBUpdate

func (p *ConfigActions) OnPostDBUpdate(hooks ...goja.Value) error

func (*ConfigActions) OnPostResolve

func (p *ConfigActions) OnPostResolve(hooks ...goja.Value) (err error)

func (*ConfigActions) OnPreDBCreate

func (p *ConfigActions) OnPreDBCreate(hooks ...goja.Value) error

func (*ConfigActions) OnPreDBDelete

func (p *ConfigActions) OnPreDBDelete(hooks ...goja.Value) error

func (*ConfigActions) OnPreDBExec

func (p *ConfigActions) OnPreDBExec(hooks ...goja.Value) error

func (*ConfigActions) OnPreDBQuery

func (p *ConfigActions) OnPreDBQuery(hooks ...goja.Value) (err error)

func (*ConfigActions) OnPreDBUpdate

func (p *ConfigActions) OnPreDBUpdate(hooks ...goja.Value) error

func (*ConfigActions) OnPreResolve

func (p *ConfigActions) OnPreResolve(hooks ...goja.Value) (err error)

type DB

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

func NewDB

func NewDB(db db.Client) *DB

func (*DB) Builder

func (d *DB) Builder(schemaName string) (*Builder, error)

func (*DB) Commit

func (d *DB) Commit() error

func (*DB) Exec

func (d *DB) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*DB) Query

func (d *DB) Query(ctx context.Context, query string, args ...any) ([]*entity.Entity, error)

func (*DB) Rollback

func (d *DB) Rollback() error

func (*DB) Tx

func (d *DB) Tx(ctx context.Context) (*DB, error)

type GetVMSet

type GetVMSet = func() map[string]any

type Manager

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

func NewManager

func NewManager(pluginsDir string) (*Manager, error)

func (*Manager) Config

func (m *Manager) Config(app fs.App) error

Config allows plugins to update the app configuration

It is called before the app is initialized

func (*Manager) Init

func (m *Manager) Init(app fs.App) error

Init initializes the plugin

It is called after the app is initialized and after the Config method is called

type Plugin

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

func NewPlugin

func NewPlugin(file string) (*Plugin, error)

func (*Plugin) Config

func (p *Plugin) Config(app AppLike) (err error)

func (*Plugin) Init

func (p *Plugin) Init(app AppLike) (err error)

func (*Plugin) Name

func (p *Plugin) Name() string

type Program

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

func NewProgram

func NewProgram(program *goja.Program, key string) *Program

func (*Program) CallFunc

func (p *Program) CallFunc(functionName string, set map[string]any, args ...any) (any, error)

func (*Program) VerifyJsFunc

func (p *Program) VerifyJsFunc(functionValue goja.Value) (string, error)

func (*Program) WithFuncName

func (p *Program) WithFuncName(functionValue goja.Value, cb func(string)) error

type Resource

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

func NewResource

func NewResource(
	fsResource *fs.Resource,
	program *Program,
	set map[string]any,
) *Resource

func (*Resource) Add

func (r *Resource) Add(handler goja.Value, metas ...*fs.Meta) (*Resource, error)

func (*Resource) Find

func (r *Resource) Find(resourceID string) *fs.Resource

func (*Resource) Group

func (r *Resource) Group(name string, metas ...*fs.Meta) *Resource

type VM

type VM struct {
	*goja.Runtime
	// contains filtered or unexported fields
}

func (*VM) RunWithSets

func (vm *VM) RunWithSets(program *Program, sets ...map[string]any) (any, error)

type VMPool

type VMPool struct {
	sync.Pool
}

func (*VMPool) Get

func (p *VMPool) Get() *VM

type VMPools

type VMPools struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*VMPools) Get

func (p *VMPools) Get(props *VMProps) *VMPool

type VMProps

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

func CreateVMProps

func CreateVMProps(function string, program *Program, set map[string]any) *VMProps

func (*VMProps) Key

func (p *VMProps) Key() string

Jump to

Keyboard shortcuts

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