Files
upstream-corteza/server/compose/automation/notification_handler.gen.go
upstream-mirror 7e385fc126
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
2026-09-18 01:22:23 +05:00

215 lines
5.3 KiB
Go
Generated

package automation
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// compose/automation/notification_handler.yaml
import (
"context"
atypes "github.com/cortezaproject/corteza/server/automation/types"
"github.com/cortezaproject/corteza/server/pkg/expr"
"github.com/cortezaproject/corteza/server/pkg/wfexec"
)
var _ wfexec.ExecResponse
type (
notificationHandlerRegistry interface {
AddFunctions(ff ...*atypes.Function)
Type(ref string) expr.Type
}
)
func (h notificationHandler) register() {
h.reg.AddFunctions(
h.SendRecord(),
)
}
type (
notificationSendRecordArgs struct {
hasRecipient bool
Recipient interface{}
recipientID uint64
recipientHandle string
recipientEmail string
hasTitle bool
Title string
hasDescription bool
Description string
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
hasRecord bool
Record uint64
hasOpenMode bool
OpenMode string
hasEdit bool
Edit bool
}
)
func (a notificationSendRecordArgs) GetRecipient() (bool, uint64, string, string) {
return a.hasRecipient, a.recipientID, a.recipientHandle, a.recipientEmail
}
func (a notificationSendRecordArgs) GetModule() (bool, uint64, string) {
return a.hasModule, a.moduleID, a.moduleHandle
}
func (a notificationSendRecordArgs) GetNamespace() (bool, uint64, string) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle
}
// SendRecord function Send record notification
//
// expects implementation of sendRecord function:
//
// func (h notificationHandler) sendRecord(ctx context.Context, args *notificationSendRecordArgs) (err error) {
// return
// }
func (h notificationHandler) SendRecord() *atypes.Function {
return &atypes.Function{
Ref: "notificationSendRecord",
Kind: "function",
Labels: map[string]string(nil),
Meta: &atypes.FunctionMeta{
Short: "Send record notification",
Description: "Sends a notification that links to a specific record",
},
Parameters: []*atypes.Param{
{
Name: "recipient",
Types: []string{"ID", "Handle", "String"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Recipient",
},
},
{
Name: "title",
Types: []string{"String"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Title",
},
},
{
Name: "description",
Types: []string{"String"},
Meta: &atypes.ParamMeta{
Label: "Description",
Visual: map[string]interface{}{"input": map[string]interface{}{"type": "richtext"}},
},
},
{
Name: "module",
Types: []string{"ID", "Handle"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Module",
},
},
{
Name: "namespace",
Types: []string{"ID", "Handle"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "record",
Types: []string{"ID"},
Meta: &atypes.ParamMeta{
Label: "Record",
},
},
{
Name: "openMode",
Types: []string{"String"},
Meta: &atypes.ParamMeta{
Label: "Open mode",
Visual: map[string]interface{}{"input": map[string]interface{}{"default": "modal", "properties": map[string]interface{}{"options": []interface{}{map[string]interface{}{"text": "Open link in the same tab", "value": "sameTab"}, map[string]interface{}{"text": "Open link in a new tab", "value": "newTab"}, map[string]interface{}{"text": "Open in a modal", "value": "modal"}}}, "type": "select"}},
},
},
{
Name: "edit",
Types: []string{"Boolean"},
Meta: &atypes.ParamMeta{
Label: "Edit",
},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &notificationSendRecordArgs{
hasRecipient: in.Has("recipient"),
hasTitle: in.Has("title"),
hasDescription: in.Has("description"),
hasModule: in.Has("module"),
hasNamespace: in.Has("namespace"),
hasRecord: in.Has("record"),
hasOpenMode: in.Has("openMode"),
hasEdit: in.Has("edit"),
}
)
if err = in.Decode(args); err != nil {
return
}
// Converting Recipient argument
if args.hasRecipient {
aux := expr.Must(expr.Select(in, "recipient"))
switch aux.Type() {
case h.reg.Type("ID").Type():
args.recipientID = aux.Get().(uint64)
case h.reg.Type("Handle").Type():
args.recipientHandle = aux.Get().(string)
case h.reg.Type("String").Type():
args.recipientEmail = aux.Get().(string)
}
}
// Converting Module argument
if args.hasModule {
aux := expr.Must(expr.Select(in, "module"))
switch aux.Type() {
case h.reg.Type("ID").Type():
args.moduleID = aux.Get().(uint64)
case h.reg.Type("Handle").Type():
args.moduleHandle = aux.Get().(string)
}
}
// Converting Namespace argument
if args.hasNamespace {
aux := expr.Must(expr.Select(in, "namespace"))
switch aux.Type() {
case h.reg.Type("ID").Type():
args.namespaceID = aux.Get().(uint64)
case h.reg.Type("Handle").Type():
args.namespaceHandle = aux.Get().(string)
}
}
return out, h.sendRecord(ctx, args)
},
}
}