MCPcopy
hub / github.com/wavetermdev/waveterm / ValidateAndMarshalCommand

Function ValidateAndMarshalCommand

pkg/ijson/ijson.go:580–595  ·  view source on GitHub ↗
(command Command)

Source from the content-addressed store, hash-verified

578}
579
580func ValidateAndMarshalCommand(command Command) ([]byte, error) {
581 cmdType := getCommandType(command)
582 if cmdType != SetCommandStr && cmdType != DelCommandStr && cmdType != AppendCommandStr {
583 return nil, fmt.Errorf("unknown ijson command type %q", cmdType)
584 }
585 path := getCommandPath(command)
586 err := ValidatePath(path)
587 if err != nil {
588 return nil, err
589 }
590 barr, err := json.Marshal(command)
591 if err != nil {
592 return nil, fmt.Errorf("error marshalling ijson command to json: %w", err)
593 }
594 return barr, nil
595}
596
597func ApplyCommand(data any, command Command, budget int) (any, error) {
598 commandType := getCommandType(command)

Callers 1

AppendIJsonMethod · 0.92

Calls 3

getCommandTypeFunction · 0.85
ValidatePathFunction · 0.85
getCommandPathFunction · 0.70

Tested by

no test coverage detected