@@ -339,7 +339,7 @@ func (step *ScriptStep) UnmarshalJSON(data []byte) error {
339339 data = normalizeScriptStepJSON (data )
340340 type alias ScriptStep
341341 var raw alias
342- if err := json .Unmarshal (stripScriptStepRawKeyAliasFields (data ), & raw ); err != nil {
342+ if err := json .Unmarshal (stripScriptStepRawScalarAliasFields (data ), & raw ); err != nil {
343343 return err
344344 }
345345 * step = ScriptStep (raw )
@@ -367,30 +367,30 @@ func (step *ScriptStep) UnmarshalJSON(data []byte) error {
367367 KeyPressesCamel * json.RawMessage `json:"keyPresses"`
368368 Keypresses * json.RawMessage `json:"keypresses"`
369369 Shortcuts * json.RawMessage `json:"shortcuts"`
370- Input * string `json:"input"`
371- InputText * string `json:"input_text"`
372- InputTextCamel * string `json:"inputText"`
373- TextInput * string `json:"text_input"`
374- TextInputCamel * string `json:"textInput"`
375- KeysText * string `json:"keys_text"`
376- KeysTextCamel * string `json:"keysText"`
377- PasteText * string `json:"paste_text"`
378- PasteTextCamel * string `json:"pasteText"`
379- PastedText * string `json:"pasted_text"`
380- PastedTextCamel * string `json:"pastedText"`
381- Clipboard * string `json:"clipboard"`
370+ Input * json. RawMessage `json:"input"`
371+ InputText * json. RawMessage `json:"input_text"`
372+ InputTextCamel * json. RawMessage `json:"inputText"`
373+ TextInput * json. RawMessage `json:"text_input"`
374+ TextInputCamel * json. RawMessage `json:"textInput"`
375+ KeysText * json. RawMessage `json:"keys_text"`
376+ KeysTextCamel * json. RawMessage `json:"keysText"`
377+ PasteText * json. RawMessage `json:"paste_text"`
378+ PasteTextCamel * json. RawMessage `json:"pasteText"`
379+ PastedText * json. RawMessage `json:"pasted_text"`
380+ PastedTextCamel * json. RawMessage `json:"pastedText"`
381+ Clipboard * json. RawMessage `json:"clipboard"`
382382 Messages []Message `json:"messages"`
383383 AppendMessages []Message `json:"append_messages"`
384384 AppendMessagesCamel []Message `json:"appendMessages"`
385385 TranscriptMessages []Message `json:"transcript_messages"`
386386 TranscriptMessagesCamel []Message `json:"transcriptMessages"`
387- Status * string `json:"status"`
388- SetStatus * string `json:"set_status"`
389- SetStatusCamel * string `json:"setStatus"`
390- StatusLine * string `json:"status_line"`
391- StatusLineCamel * string `json:"statusLine"`
392- BaseStatus * string `json:"base_status"`
393- BaseStatusCamel * string `json:"baseStatus"`
387+ Status * json. RawMessage `json:"status"`
388+ SetStatus * json. RawMessage `json:"set_status"`
389+ SetStatusCamel * json. RawMessage `json:"setStatus"`
390+ StatusLine * json. RawMessage `json:"status_line"`
391+ StatusLineCamel * json. RawMessage `json:"statusLine"`
392+ BaseStatus * json. RawMessage `json:"base_status"`
393+ BaseStatusCamel * json. RawMessage `json:"baseStatus"`
394394 Mouse * ScriptMouse `json:"mouse"`
395395 MouseEvent * ScriptMouse `json:"mouse_event"`
396396 MouseEventCamel * ScriptMouse `json:"mouseEvent"`
@@ -443,8 +443,8 @@ func (step *ScriptStep) UnmarshalJSON(data []byte) error {
443443 ResizeWidthCamel * int `json:"resizeWidth"`
444444 ResizeHeight * int `json:"resize_height"`
445445 ResizeHeightCamel * int `json:"resizeHeight"`
446- SnapshotName * string `json:"snapshot_name"`
447- SnapshotNameCamel * string `json:"snapshotName"`
446+ SnapshotName * json. RawMessage `json:"snapshot_name"`
447+ SnapshotNameCamel * json. RawMessage `json:"snapshotName"`
448448 Focus * bool `json:"focus"`
449449 Focused * bool `json:"focused"`
450450 FocusIn * bool `json:"focus_in"`
@@ -581,41 +581,46 @@ func (step *ScriptStep) UnmarshalJSON(data []byte) error {
581581 ); len (values ) > 0 {
582582 step .Keys = append (step .Keys , values ... )
583583 }
584- if fields .Input != nil {
585- step .Text = * fields .Input
586- }
587- if fields .InputText != nil {
588- step .Text = * fields .InputText
589- }
590- if fields .InputTextCamel != nil {
591- step .Text = * fields .InputTextCamel
592- }
593- if fields .TextInput != nil {
594- step .Text = * fields .TextInput
595- }
596- if fields .TextInputCamel != nil {
597- step .Text = * fields .TextInputCamel
598- }
599- if fields .KeysText != nil {
600- step .Text = * fields .KeysText
601- }
602- if fields .KeysTextCamel != nil {
603- step .Text = * fields .KeysTextCamel
604- }
605- if fields .PasteText != nil {
606- step .Paste = * fields .PasteText
607- }
608- if fields .PasteTextCamel != nil {
609- step .Paste = * fields .PasteTextCamel
610- }
611- if fields .PastedText != nil {
612- step .Paste = * fields .PastedText
613- }
614- if fields .PastedTextCamel != nil {
615- step .Paste = * fields .PastedTextCamel
584+ if step .Text == "" {
585+ step .Text = scriptNamedStringField (rawFieldMap ,
586+ []string {
587+ "Text" ,
588+ "text" ,
589+ "input" ,
590+ "input_text" ,
591+ "inputText" ,
592+ "text_input" ,
593+ "textInput" ,
594+ "keys_text" ,
595+ "keysText" ,
596+ },
597+ "text" ,
598+ "input" ,
599+ "content" ,
600+ "body" ,
601+ "message" ,
602+ "value" ,
603+ )
616604 }
617- if fields .Clipboard != nil {
618- step .Paste = * fields .Clipboard
605+ if step .Paste == "" {
606+ step .Paste = scriptNamedStringField (rawFieldMap ,
607+ []string {
608+ "Paste" ,
609+ "paste" ,
610+ "paste_text" ,
611+ "pasteText" ,
612+ "pasted_text" ,
613+ "pastedText" ,
614+ "clipboard" ,
615+ },
616+ "paste" ,
617+ "clipboard" ,
618+ "text" ,
619+ "content" ,
620+ "body" ,
621+ "message" ,
622+ "value" ,
623+ )
619624 }
620625 if fields .Messages != nil {
621626 step .Messages = fields .Messages
@@ -632,26 +637,25 @@ func (step *ScriptStep) UnmarshalJSON(data []byte) error {
632637 if fields .TranscriptMessagesCamel != nil {
633638 step .Messages = fields .TranscriptMessagesCamel
634639 }
635- if fields .Status != nil {
636- step .Status = * fields .Status
637- }
638- if fields .SetStatus != nil {
639- step .Status = * fields .SetStatus
640- }
641- if fields .SetStatusCamel != nil {
642- step .Status = * fields .SetStatusCamel
643- }
644- if fields .StatusLine != nil {
645- step .Status = * fields .StatusLine
646- }
647- if fields .StatusLineCamel != nil {
648- step .Status = * fields .StatusLineCamel
649- }
650- if fields .BaseStatus != nil {
651- step .Status = * fields .BaseStatus
652- }
653- if fields .BaseStatusCamel != nil {
654- step .Status = * fields .BaseStatusCamel
640+ if step .Status == "" {
641+ step .Status = scriptNamedStringField (rawFieldMap ,
642+ []string {
643+ "Status" ,
644+ "status" ,
645+ "set_status" ,
646+ "setStatus" ,
647+ "status_line" ,
648+ "statusLine" ,
649+ "base_status" ,
650+ "baseStatus" ,
651+ },
652+ "status" ,
653+ "text" ,
654+ "message" ,
655+ "content" ,
656+ "body" ,
657+ "value" ,
658+ )
655659 }
656660 if fields .Mouse != nil {
657661 step .Mouse = fields .Mouse
@@ -742,14 +746,28 @@ func (step *ScriptStep) UnmarshalJSON(data []byte) error {
742746 step .ResizeHeight = * height
743747 }
744748 }
745- if fields .SnapshotName != nil {
746- step .SnapshotName = * fields .SnapshotName
747- }
748- if fields .SnapshotNameCamel != nil {
749- step .SnapshotName = * fields .SnapshotNameCamel
750- }
751749 if step .SnapshotName == "" {
752- step .SnapshotName = stringJSONField (fieldMap , "snapshot" , "snapshot_id" , "snapshotId" , "snapshot_label" , "snapshotLabel" , "capture_name" , "captureName" , "baseline_name" , "baselineName" )
750+ step .SnapshotName = scriptNamedStringField (rawFieldMap ,
751+ []string {
752+ "SnapshotName" ,
753+ "snapshotName" ,
754+ "snapshot_name" ,
755+ "snapshot" ,
756+ "snapshot_id" ,
757+ "snapshotId" ,
758+ "snapshot_label" ,
759+ "snapshotLabel" ,
760+ "capture_name" ,
761+ "captureName" ,
762+ "baseline_name" ,
763+ "baselineName" ,
764+ },
765+ "snapshot" ,
766+ "name" ,
767+ "label" ,
768+ "id" ,
769+ "value" ,
770+ )
753771 }
754772 if fields .Focus != nil {
755773 step .Keys = append (step .Keys , scriptFocusKey (* fields .Focus ))
@@ -1688,6 +1706,19 @@ func scriptActionStringField(fields map[string]json.RawMessage, objectNames ...s
16881706 return ""
16891707}
16901708
1709+ func scriptNamedStringField (fields map [string ]json.RawMessage , directNames []string , nestedNames ... string ) string {
1710+ for _ , name := range directNames {
1711+ raw , ok := fields [name ]
1712+ if ! ok {
1713+ continue
1714+ }
1715+ if value := scriptActionStringFromJSON (raw , nestedNames , 0 ); value != "" {
1716+ return value
1717+ }
1718+ }
1719+ return ""
1720+ }
1721+
16911722func scriptActionStringListField (fields map [string ]json.RawMessage , names ... string ) []string {
16921723 for _ , name := range append ([]string {"value" , "payload" , "data" , "body" }, names ... ) {
16931724 raw , ok := fields [name ]
@@ -2165,13 +2196,26 @@ func normalizeScriptStepJSON(data []byte) []byte {
21652196 )
21662197}
21672198
2168- func stripScriptStepRawKeyAliasFields (data []byte ) []byte {
2199+ func stripScriptStepRawScalarAliasFields (data []byte ) []byte {
21692200 var fields map [string ]json.RawMessage
21702201 if err := json .Unmarshal (data , & fields ); err != nil {
21712202 return data
21722203 }
21732204 changed := false
2174- for _ , name := range []string {"Key" , "key" , "Keys" , "keys" } {
2205+ for _ , name := range []string {
2206+ "Key" ,
2207+ "key" ,
2208+ "Keys" ,
2209+ "keys" ,
2210+ "Text" ,
2211+ "text" ,
2212+ "Paste" ,
2213+ "paste" ,
2214+ "Status" ,
2215+ "status" ,
2216+ "SnapshotName" ,
2217+ "snapshotName" ,
2218+ } {
21752219 raw , ok := fields [name ]
21762220 if ! ok {
21772221 continue
0 commit comments