Skip to content

Commit

Permalink
feat: script action (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesleysin authored Feb 18, 2024
1 parent f0aee4e commit dcbbc31
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/duit_core/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ package duit_core
const (
Transport = iota
Local
Script
)

type ActionDependency struct {
Id string `json:"id"`
Target string `json:"target"`
}

type ScriptData struct {
SourceCode string `json:"sourceCode"`
FunctionName string `json:"functionName"`
Meta interface{} `json:"meta,omitempty"`
}

// Event is a string field that represents the event associated with the action.
//
// DependsOn is a string slice field that represents the dependencies of the action.
Expand All @@ -21,4 +28,5 @@ type Action struct {
DependsOn []*ActionDependency `json:"dependsOn"`
Meta interface{} `json:"meta,omitempty"`
Payload *Event `json:"payload,omitempty"`
Script *ScriptData `json:"script,omitempty"`
}
9 changes: 9 additions & 0 deletions pkg/duit_core/action_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,12 @@ func CreateLocalExecutedtAction(payload *Event) *Action {
Payload: payload,
}
}

func CreateScriptAction(event string, dependsOn []*ActionDependency, script *ScriptData) *Action {
return &Action{
ExecutionType: Script,
Event: event,
DependsOn: dependsOn,
Script: script,
}
}

0 comments on commit dcbbc31

Please sign in to comment.