mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-29 14:25:31 +00:00
generate json-schema dynamically in Go
This commit is contained in:
@@ -40,7 +40,8 @@ func (apd *ArtNetPacketDecode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "artnet.packet.decode",
|
||||
Type: "artnet.packet.decode",
|
||||
Title: "Decode ArtNet Packet",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &ArtNetPacketDecode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -39,7 +39,8 @@ func (ape *ArtNetPacketEncode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "artnet.packet.encode",
|
||||
Type: "artnet.packet.encode",
|
||||
Title: "Encode ArtNet Packet",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &ArtNetPacketEncode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -104,7 +104,8 @@ func (dq *DbQuery) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "db.query",
|
||||
Type: "db.query",
|
||||
Title: "Query Database",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
|
||||
params := config.Params
|
||||
|
||||
@@ -28,7 +28,8 @@ func (dl *DebugLog) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "debug.log",
|
||||
Type: "debug.log",
|
||||
Title: "Debug Log",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &DebugLog{config: config, logger: slog.Default().With("component", "processor", "type", config.Type)}, nil
|
||||
},
|
||||
|
||||
@@ -31,7 +31,8 @@ func (fc *FilterChange) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "filter.change",
|
||||
Type: "filter.change",
|
||||
Title: "Filter On Change",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &FilterChange{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/expr-lang/expr"
|
||||
"github.com/expr-lang/expr/vm"
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -47,7 +48,19 @@ func (fe *FilterExpr) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "filter.expr",
|
||||
Type: "filter.expr",
|
||||
Title: "Filter by Expr expression",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"expression": {
|
||||
Title: "Expression",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"expression"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -39,7 +40,19 @@ func (fr *FilterRegex) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "filter.regex",
|
||||
Type: "filter.regex",
|
||||
Title: "Filter by Regex",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"pattern": {
|
||||
Title: "Pattern",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"pattern"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ package processor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -39,7 +41,20 @@ func (fp *FloatParse) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "float.parse",
|
||||
Type: "float.parse",
|
||||
Title: "Parse Float",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"bitSize": {
|
||||
Title: "Bit Size",
|
||||
Type: "integer",
|
||||
Enum: []any{32, 64},
|
||||
Default: json.RawMessage("64"),
|
||||
},
|
||||
},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(moduleConfig config.ProcessorConfig) (Processor, error) {
|
||||
params := moduleConfig.Params
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ package processor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand/v2"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -38,7 +40,29 @@ func (fr *FloatRandom) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "float.random",
|
||||
Type: "float.random",
|
||||
Title: "Random Float",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"bitSize": {
|
||||
Title: "Bit Size",
|
||||
Type: "integer",
|
||||
Enum: []any{32, 64},
|
||||
Default: json.RawMessage("32"),
|
||||
},
|
||||
"min": {
|
||||
Title: "Minimum",
|
||||
Type: "number",
|
||||
},
|
||||
"max": {
|
||||
Title: "Maximum",
|
||||
Type: "number",
|
||||
},
|
||||
},
|
||||
Required: []string{"min", "max"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(processorConfig config.ProcessorConfig) (Processor, error) {
|
||||
params := processorConfig.Params
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strconv"
|
||||
"text/template"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
freeD "github.com/jwetzell/free-d-go"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
@@ -205,7 +206,61 @@ func (fc *FreeDCreate) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "freed.create",
|
||||
Type: "freed.create",
|
||||
Title: "Create FreeD",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"id": {
|
||||
Title: "Camera ID",
|
||||
Type: "string",
|
||||
},
|
||||
"pan": {
|
||||
Title: "Pan",
|
||||
Type: "string",
|
||||
},
|
||||
"tilt": {
|
||||
Title: "Tilt",
|
||||
Type: "string",
|
||||
},
|
||||
"roll": {
|
||||
Title: "Roll",
|
||||
Type: "string",
|
||||
},
|
||||
"posX": {
|
||||
Title: "Position X",
|
||||
Type: "string",
|
||||
},
|
||||
"posY": {
|
||||
Title: "Position Y",
|
||||
Type: "string",
|
||||
},
|
||||
"posZ": {
|
||||
Title: "Position Z",
|
||||
Type: "string",
|
||||
},
|
||||
"zoom": {
|
||||
Title: "Zoom",
|
||||
Type: "string",
|
||||
},
|
||||
"focus": {
|
||||
Title: "Focus",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{
|
||||
"id",
|
||||
"pan",
|
||||
"tilt",
|
||||
"roll",
|
||||
"posX",
|
||||
"posY",
|
||||
"posZ",
|
||||
"zoom",
|
||||
"focus",
|
||||
},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
|
||||
// TODO(jwetzell): make some params optional
|
||||
|
||||
@@ -37,7 +37,8 @@ func (fd *FreeDDecode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "freed.decode",
|
||||
Type: "freed.decode",
|
||||
Title: "Decode FreeD",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &FreeDDecode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -34,7 +34,8 @@ func (fe *FreeDEncode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "freed.encode",
|
||||
Type: "freed.encode",
|
||||
Title: "Encode FreeD",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &FreeDEncode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -70,7 +71,24 @@ func (hrd *HTTPRequestDo) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "http.request.do",
|
||||
Type: "http.request.do",
|
||||
Title: "Do HTTP Request",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"method": {
|
||||
Title: "HTTP Method",
|
||||
Type: "string",
|
||||
Enum: []any{"GET", "POST"},
|
||||
},
|
||||
"url": {
|
||||
Title: "URL",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"method", "url"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"text/template"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -44,7 +45,23 @@ func (hrc *HTTPResponseCreate) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "http.response.create",
|
||||
Type: "http.response.create",
|
||||
Title: "Create HTTP Response",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"status": {
|
||||
Title: "Status Code",
|
||||
Type: "integer",
|
||||
},
|
||||
"body": {
|
||||
Title: "Body",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"status", "body"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ package processor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -40,7 +42,26 @@ func (ip *IntParse) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "int.parse",
|
||||
Type: "int.parse",
|
||||
Title: "Parse Int",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"base": {
|
||||
Title: "Base",
|
||||
Type: "integer",
|
||||
Enum: []any{0, 2, 8, 10, 16},
|
||||
Default: json.RawMessage("10"),
|
||||
},
|
||||
"bitSize": {
|
||||
Title: "Bit Size",
|
||||
Type: "integer",
|
||||
Enum: []any{0, 8, 16, 32, 64},
|
||||
Default: json.RawMessage("64"),
|
||||
},
|
||||
},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(moduleConfig config.ProcessorConfig) (Processor, error) {
|
||||
params := moduleConfig.Params
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand/v2"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -28,7 +29,23 @@ func (ir *IntRandom) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "int.random",
|
||||
Type: "int.random",
|
||||
Title: "Random Int",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"min": {
|
||||
Title: "Minimum",
|
||||
Type: "integer",
|
||||
},
|
||||
"max": {
|
||||
Title: "Maximum",
|
||||
Type: "integer",
|
||||
},
|
||||
},
|
||||
Required: []string{"min", "max"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -36,7 +37,31 @@ func (ir *IntScale) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "int.scale",
|
||||
Type: "int.scale",
|
||||
Title: "Scale Int",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"inMin": {
|
||||
Title: "Input Minimum",
|
||||
Type: "integer",
|
||||
},
|
||||
"inMax": {
|
||||
Title: "Input Maximum",
|
||||
Type: "integer",
|
||||
},
|
||||
"outMin": {
|
||||
Title: "Output Minimum",
|
||||
Type: "integer",
|
||||
},
|
||||
"outMax": {
|
||||
Title: "Output Maximum",
|
||||
Type: "integer",
|
||||
},
|
||||
},
|
||||
Required: []string{"inMin", "inMax", "outMin", "outMax"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ func (jd *JsonDecode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "json.decode",
|
||||
Type: "json.decode",
|
||||
Title: "Decode JSON",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &JsonDecode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -38,7 +38,8 @@ func (je *JsonEncode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "json.encode",
|
||||
Type: "json.encode",
|
||||
Title: "Encode JSON",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &JsonEncode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -51,7 +52,23 @@ func (kvg *KVGet) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "kv.get",
|
||||
Type: "kv.get",
|
||||
Title: "Get Key",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"module": {
|
||||
Title: "Module ID",
|
||||
Type: "string",
|
||||
},
|
||||
"key": {
|
||||
Title: "Key",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"module", "key"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
|
||||
params := config.Params
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"html/template"
|
||||
"log/slog"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -62,7 +63,27 @@ func (kvs *KVSet) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "kv.set",
|
||||
Type: "kv.set",
|
||||
Title: "Set Key",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"module": {
|
||||
Title: "Module ID",
|
||||
Type: "string",
|
||||
},
|
||||
"key": {
|
||||
Title: "Key",
|
||||
Type: "string",
|
||||
},
|
||||
"value": {
|
||||
Title: "Value",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"module", "key", "value"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
|
||||
params := config.Params
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"strconv"
|
||||
"text/template"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
"gitlab.com/gomidi/midi/v2"
|
||||
@@ -314,7 +315,105 @@ func newMidiProgramChangeCreate(config config.ProcessorConfig) (Processor, error
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "midi.message.create",
|
||||
Type: "midi.message.create",
|
||||
Title: "Create MIDI Message",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
OneOf: []*jsonschema.Schema{
|
||||
{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"type": {
|
||||
Title: "MIDI Message Type",
|
||||
Type: "string",
|
||||
Enum: []any{"NoteOn", "noteon", "note_on"},
|
||||
},
|
||||
"channel": {
|
||||
Title: "Channel",
|
||||
Type: "string",
|
||||
},
|
||||
"note": {
|
||||
Title: "Note",
|
||||
Type: "string",
|
||||
},
|
||||
"velocity": {
|
||||
Title: "Velocity",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"type", "channel", "note", "velocity"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"type": {
|
||||
Title: "MIDI Message Type",
|
||||
Type: "string",
|
||||
Enum: []any{"NoteOff", "noteoff", "note_off"},
|
||||
},
|
||||
"channel": {
|
||||
Title: "Channel",
|
||||
Type: "string",
|
||||
},
|
||||
"note": {
|
||||
Title: "Note",
|
||||
Type: "string",
|
||||
},
|
||||
"velocity": {
|
||||
Title: "Velocity",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"type", "channel", "note", "velocity"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"type": {
|
||||
Title: "MIDI Message Type",
|
||||
Type: "string",
|
||||
Enum: []any{"ControlChange", "controlchange", "control_change"},
|
||||
},
|
||||
"channel": {
|
||||
Title: "Channel",
|
||||
Type: "string",
|
||||
},
|
||||
"control": {
|
||||
Title: "Control",
|
||||
Type: "string",
|
||||
},
|
||||
"value": {
|
||||
Title: "Value",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"type", "channel", "control", "value"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"type": {
|
||||
Title: "MIDI Message Type",
|
||||
Type: "string",
|
||||
Enum: []any{"ProgramChange", "programchange", "program_change"},
|
||||
},
|
||||
"channel": {
|
||||
Title: "Channel",
|
||||
Type: "string",
|
||||
},
|
||||
"program": {
|
||||
Title: "Program",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"type", "channel", "program"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ func (mmd *MIDIMessageDecode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "midi.message.decode",
|
||||
Type: "midi.message.decode",
|
||||
Title: "Decode MIDI Message",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &MIDIMessageDecode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -34,7 +34,8 @@ func (mme *MIDIMessageEncode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "midi.message.encode",
|
||||
Type: "midi.message.encode",
|
||||
Title: "Encode MIDI Message",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &MIDIMessageEncode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -92,7 +92,8 @@ func (mmu *MIDIMessageUnpack) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "midi.message.unpack",
|
||||
Type: "midi.message.unpack",
|
||||
Title: "Unpack MIDI Message",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &MIDIMessageUnpack{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -80,7 +81,31 @@ func (mmc *MQTTMessageCreate) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "mqtt.message.create",
|
||||
Type: "mqtt.message.create",
|
||||
Title: "Create MQTT Message",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"topic": {
|
||||
Title: "Topic",
|
||||
Type: "string",
|
||||
},
|
||||
"qos": {
|
||||
Title: "QoS",
|
||||
Type: "number",
|
||||
},
|
||||
"retained": {
|
||||
Title: "Retained",
|
||||
Type: "boolean",
|
||||
},
|
||||
"payload": {
|
||||
Title: "Payload",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"topic", "qos", "retained", "payload"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(processorConfig config.ProcessorConfig) (Processor, error) {
|
||||
params := processorConfig.Params
|
||||
topicString, err := params.GetString("topic")
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"text/template"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -59,7 +60,23 @@ func (nmc *NATSMessageCreate) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "nats.message.create",
|
||||
Type: "nats.message.create",
|
||||
Title: "Create NATS Message",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"subject": {
|
||||
Title: "Subject",
|
||||
Type: "string",
|
||||
},
|
||||
"payload": {
|
||||
Title: "Payload",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"subject", "payload"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
subjectString, err := params.GetString("subject")
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"strconv"
|
||||
"text/template"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/osc-go"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
@@ -86,7 +87,30 @@ func (omc *OSCMessageCreate) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "osc.message.create",
|
||||
Type: "osc.message.create",
|
||||
Title: "Create OSC Message",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"address": {
|
||||
Title: "Address",
|
||||
Type: "string",
|
||||
},
|
||||
"args": {
|
||||
Title: "Arguments",
|
||||
Type: "array",
|
||||
Items: &jsonschema.Schema{
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
"types": {
|
||||
Title: "Argument Types",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"address"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(processorConfig config.ProcessorConfig) (Processor, error) {
|
||||
params := processorConfig.Params
|
||||
addressString, err := params.GetString("address")
|
||||
|
||||
@@ -48,7 +48,8 @@ func (omd *OSCMessageDecode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "osc.message.decode",
|
||||
Type: "osc.message.decode",
|
||||
Title: "Decode OSC Message",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &OSCMessageDecode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -32,7 +32,8 @@ func (ome *OSCMessageEncode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "osc.message.encode",
|
||||
Type: "osc.message.encode",
|
||||
Title: "Encode OSC Message",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &OSCMessageEncode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -15,8 +16,11 @@ type Processor interface {
|
||||
}
|
||||
|
||||
type ProcessorRegistration struct {
|
||||
Type string `json:"type"`
|
||||
New func(config.ProcessorConfig) (Processor, error)
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ParamsSchema *jsonschema.Schema `json:"paramsSchema,omitempty"`
|
||||
New func(config.ProcessorConfig) (Processor, error)
|
||||
}
|
||||
|
||||
func RegisterProcessor(processor ProcessorRegistration) {
|
||||
@@ -41,3 +45,45 @@ var (
|
||||
processorRegistryMu sync.RWMutex
|
||||
ProcessorRegistry = make(map[string]ProcessorRegistration)
|
||||
)
|
||||
|
||||
func GetProcessorsSchema() *jsonschema.Schema {
|
||||
processorRegistryMu.RLock()
|
||||
defer processorRegistryMu.RUnlock()
|
||||
|
||||
schema := &jsonschema.Schema{
|
||||
Schema: "https://json-schema.org/draft/2020-12/schema",
|
||||
ID: "https://showbridge.io/processors.schema.json",
|
||||
Title: "Processors",
|
||||
Description: "processor configurations",
|
||||
Type: "array",
|
||||
}
|
||||
|
||||
processorDefinitionSchemas := []*jsonschema.Schema{}
|
||||
for _, proc := range ProcessorRegistry {
|
||||
processorSchema := &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"type": {
|
||||
Const: jsonschema.Ptr[any](proc.Type),
|
||||
},
|
||||
},
|
||||
Required: []string{"type"},
|
||||
AdditionalProperties: nil,
|
||||
}
|
||||
if proc.Title != "" {
|
||||
processorSchema.Title = proc.Title
|
||||
}
|
||||
if proc.Description != "" {
|
||||
processorSchema.Description = proc.Description
|
||||
}
|
||||
if proc.ParamsSchema != nil {
|
||||
processorSchema.Properties["params"] = proc.ParamsSchema
|
||||
processorSchema.Required = append(processorSchema.Required, "params")
|
||||
}
|
||||
processorDefinitionSchemas = append(processorDefinitionSchemas, processorSchema)
|
||||
}
|
||||
schema.Items = &jsonschema.Schema{
|
||||
OneOf: processorDefinitionSchemas,
|
||||
}
|
||||
return schema
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -44,7 +45,20 @@ func (ro *RouterInput) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "router.input",
|
||||
Type: "router.input",
|
||||
Title: "Router Input",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"source": {
|
||||
Title: "Source",
|
||||
Type: "string",
|
||||
Description: "source to report as to the router",
|
||||
},
|
||||
},
|
||||
Required: []string{"source"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
|
||||
params := config.Params
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -40,7 +41,20 @@ func (ro *RouterOutput) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "router.output",
|
||||
Type: "router.output",
|
||||
Title: "Router Output",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"module": {
|
||||
Title: "Module ID",
|
||||
Type: "string",
|
||||
Description: "ID of module to send output to",
|
||||
},
|
||||
},
|
||||
Required: []string{"module"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
|
||||
params := config.Params
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/expr-lang/expr"
|
||||
"github.com/expr-lang/expr/vm"
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -36,7 +37,19 @@ func (se *ScriptExpr) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "script.expr",
|
||||
Type: "script.expr",
|
||||
Title: "Evaluate Expr Expression",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"expression": {
|
||||
Title: "Expression",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"expression"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
"modernc.org/quickjs"
|
||||
@@ -21,9 +22,9 @@ func (sj *ScriptJS) Process(ctx context.Context, wrappedPayload common.WrappedPa
|
||||
|
||||
//NOTE(jwetzell): some weird conversion going on with these types
|
||||
_, isUint8Slice := common.GetAnyAs[[]uint8](wrappedPayload.Payload)
|
||||
_, isbyteSlice := common.GetAnyAs[[]byte](wrappedPayload.Payload)
|
||||
_, isByteSlice := common.GetAnyAs[[]byte](wrappedPayload.Payload)
|
||||
|
||||
if isUint8Slice || isbyteSlice {
|
||||
if isUint8Slice || isByteSlice {
|
||||
intSlice, ok := common.GetAnyAsIntSlice(wrappedPayload.Payload)
|
||||
|
||||
if ok {
|
||||
@@ -93,7 +94,19 @@ func (sj *ScriptJS) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "script.js",
|
||||
Type: "script.js",
|
||||
Title: "Run JavaScript",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"program": {
|
||||
Title: "Program",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"program"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ package processor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
extism "github.com/extism/go-sdk"
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -50,7 +52,29 @@ func (sw *ScriptWASM) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "script.wasm",
|
||||
Type: "script.wasm",
|
||||
Title: "Run WASM Plugin",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"path": {
|
||||
Title: "Path",
|
||||
Type: "string",
|
||||
},
|
||||
"function": {
|
||||
Title: "Function",
|
||||
Type: "string",
|
||||
Default: json.RawMessage(`"process"`),
|
||||
},
|
||||
"enableWasi": {
|
||||
Title: "Enable WASI",
|
||||
Type: "boolean",
|
||||
Default: json.RawMessage("false"),
|
||||
},
|
||||
},
|
||||
Required: []string{"path"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(processorConfig config.ProcessorConfig) (Processor, error) {
|
||||
params := processorConfig.Params
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"text/template"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -51,7 +52,26 @@ func (srac *SipResponseAudioCreate) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "sip.response.audio.create",
|
||||
Type: "sip.response.audio.create",
|
||||
Title: "Create SIP Audio Response",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"preWait": {
|
||||
Title: "Pre Wait (ms)",
|
||||
Type: "integer",
|
||||
},
|
||||
"postWait": {
|
||||
Title: "Post Wait (ms)",
|
||||
Type: "integer",
|
||||
},
|
||||
"audioFile": {
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"preWait", "postWait", "audioFile"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"regexp"
|
||||
"text/template"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -59,7 +60,26 @@ func (srdc *SipResponseDTMFCreate) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "sip.response.dtmf.create",
|
||||
Type: "sip.response.dtmf.create",
|
||||
Title: "Create SIP DTMF Response",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"preWait": {
|
||||
Title: "Pre Wait (ms)",
|
||||
Type: "integer",
|
||||
},
|
||||
"postWait": {
|
||||
Title: "Post Wait (ms)",
|
||||
Type: "integer",
|
||||
},
|
||||
"digits": {
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"preWait", "postWait", "digits"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"text/template"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -37,7 +38,19 @@ func (sc *StringCreate) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "string.create",
|
||||
Type: "string.create",
|
||||
Title: "Create String",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"template": {
|
||||
Title: "Template",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"template"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
templateString, err := params.GetString("template")
|
||||
|
||||
@@ -33,7 +33,8 @@ func (sd *StringDecode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "string.decode",
|
||||
Type: "string.decode",
|
||||
Title: "Decode String",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &StringDecode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -32,7 +32,8 @@ func (se *StringEncode) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "string.encode",
|
||||
Type: "string.encode",
|
||||
Title: "Encode String",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &StringEncode{config: config}, nil
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -35,7 +36,19 @@ func (ss *StringSplit) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "string.split",
|
||||
Type: "string.split",
|
||||
Title: "Split String",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"separator": {
|
||||
Title: "Separator",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"separator"},
|
||||
AdditionalProperties: nil,
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -44,7 +45,18 @@ func (sf *StructFieldGet) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "struct.field.get",
|
||||
Type: "struct.field.get",
|
||||
Title: "Get Struct Field",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"name": {
|
||||
Title: "Field Name",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"name"},
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
nameString, err := params.GetString("name")
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -63,7 +64,18 @@ func (sm *StructMethodGet) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "struct.method.get",
|
||||
Type: "struct.method.get",
|
||||
Title: "Get Struct Method",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"name": {
|
||||
Title: "Method Name",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"name"},
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
nameString, err := params.GetString("name")
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
@@ -25,7 +26,19 @@ func (ts *TimeSleep) Type() string {
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "time.sleep",
|
||||
Type: "time.sleep",
|
||||
Title: "Sleep",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"duration": {
|
||||
Title: "Duration",
|
||||
Type: "integer",
|
||||
Description: "Duration to sleep in milliseconds",
|
||||
},
|
||||
},
|
||||
Required: []string{"duration"},
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
|
||||
|
||||
Reference in New Issue
Block a user