Files
upstream-corteza/server/compose/automation/records_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

1847 lines
44 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/records_handler.yaml
import (
"context"
atypes "github.com/cortezaproject/corteza/server/automation/types"
"github.com/cortezaproject/corteza/server/compose/types"
"github.com/cortezaproject/corteza/server/pkg/expr"
"github.com/cortezaproject/corteza/server/pkg/wfexec"
)
var _ wfexec.ExecResponse
type (
recordsHandlerRegistry interface {
AddFunctions(ff ...*atypes.Function)
Type(ref string) expr.Type
}
)
func (h recordsHandler) register() {
h.reg.AddFunctions(
h.Lookup(),
h.Search(),
h.First(),
h.Last(),
h.Each(),
h.New(),
h.Validate(),
h.Create(),
h.Update(),
h.Delete(),
h.Report(),
h.Clone(),
)
}
type (
recordsLookupArgs struct {
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
namespaceRes *types.Namespace
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
moduleRes *types.Module
hasRecord bool
Record interface{}
recordID uint64
recordRes *types.Record
}
recordsLookupResults struct {
Record *types.Record
}
)
func (a recordsLookupArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
}
func (a recordsLookupArgs) GetModule() (bool, uint64, string, *types.Module) {
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
}
func (a recordsLookupArgs) GetRecord() (bool, uint64, *types.Record) {
return a.hasRecord, a.recordID, a.recordRes
}
// Lookup function Compose record lookup
//
// expects implementation of lookup function:
//
// func (h recordsHandler) lookup(ctx context.Context, args *recordsLookupArgs) (results *recordsLookupResults, err error) {
// return
// }
func (h recordsHandler) Lookup() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsLookup",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose record lookup",
Description: "Find specific record by ID",
},
Parameters: []*atypes.Param{
{
Name: "namespace",
Types: []string{"ID", "Handle", "ComposeNamespace"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "module",
Types: []string{"ID", "Handle", "ComposeModule"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Module",
Description: "Even with unique record ID across all modules, module needs to be known\nbefore doing any record operations. Mainly because records of different\nmodules can be located in different stores.",
},
},
{
Name: "record",
Types: []string{"ID", "ComposeRecord"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Record",
},
},
},
Results: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsLookupArgs{
hasNamespace: in.Has("namespace"),
hasModule: in.Has("module"),
hasRecord: in.Has("record"),
}
)
if err = in.Decode(args); err != nil {
return
}
// 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)
case h.reg.Type("ComposeNamespace").Type():
args.namespaceRes = aux.Get().(*types.Namespace)
}
}
// 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)
case h.reg.Type("ComposeModule").Type():
args.moduleRes = aux.Get().(*types.Module)
}
}
// Converting Record argument
if args.hasRecord {
aux := expr.Must(expr.Select(in, "record"))
switch aux.Type() {
case h.reg.Type("ID").Type():
args.recordID = aux.Get().(uint64)
case h.reg.Type("ComposeRecord").Type():
args.recordRes = aux.Get().(*types.Record)
}
}
var results *recordsLookupResults
if results, err = h.lookup(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Record (*types.Record) to ComposeRecord
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("ComposeRecord").Cast(results.Record); err != nil {
return
} else if err = expr.Assign(out, "record", tval); err != nil {
return
}
}
return
},
}
}
type (
recordsSearchArgs struct {
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
namespaceRes *types.Namespace
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
moduleRes *types.Module
hasQuery bool
Query string
hasMeta bool
Meta map[string]any
hasDeleted bool
Deleted uint64
hasSort bool
Sort string
hasLimit bool
Limit uint64
hasIncTotal bool
IncTotal bool
hasIncPageNavigation bool
IncPageNavigation bool
hasPageCursor bool
PageCursor string
}
recordsSearchResults struct {
Records []*types.Record
Total uint64
NextPage string
PrevPage string
PageNavigation []expr.TypedValue
}
)
func (a recordsSearchArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
}
func (a recordsSearchArgs) GetModule() (bool, uint64, string, *types.Module) {
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
}
// Search function Compose records search
//
// expects implementation of search function:
//
// func (h recordsHandler) search(ctx context.Context, args *recordsSearchArgs) (results *recordsSearchResults, err error) {
// return
// }
func (h recordsHandler) Search() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsSearch",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose records search",
},
Parameters: []*atypes.Param{
{
Name: "namespace",
Types: []string{"ID", "Handle", "ComposeNamespace"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "module",
Types: []string{"ID", "Handle", "ComposeModule"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Module",
Description: "Even with unique record ID across all modules, module needs to be known\nbefore doing any record operations. Mainly because records of different\nmodules can be located in different stores.",
},
},
{
Name: "query",
Types: []string{"String"},
Meta: &atypes.ParamMeta{
Label: "Query",
},
},
{
Name: "meta",
Types: []string{"Meta"},
Meta: &atypes.ParamMeta{
Label: "Meta",
},
},
{
Name: "deleted",
Types: []string{"UnsignedInteger"},
Meta: &atypes.ParamMeta{
Label: "Deleted",
},
},
{
Name: "sort",
Types: []string{"String"},
Meta: &atypes.ParamMeta{
Label: "Sort",
},
},
{
Name: "limit",
Types: []string{"UnsignedInteger"},
Meta: &atypes.ParamMeta{
Label: "Limit",
},
},
{
Name: "incTotal",
Types: []string{"Boolean"},
Meta: &atypes.ParamMeta{
Label: "Include total",
},
},
{
Name: "incPageNavigation",
Types: []string{"Boolean"},
Meta: &atypes.ParamMeta{
Label: "Include page navigation",
},
},
{
Name: "pageCursor",
Types: []string{"String"},
Meta: &atypes.ParamMeta{
Label: "Page cursor",
},
},
},
Results: []*atypes.Param{
{
Name: "records",
Types: []string{"ComposeRecord"},
IsArray: true,
},
{
Name: "total",
Types: []string{"UnsignedInteger"},
Meta: &atypes.ParamMeta{
Label: "Total records found",
Description: "Total items that satisfy given conditions.\n\nNeeds to be explicitly requested with incTotal argument",
},
},
{
Name: "nextPage",
Types: []string{"String"},
},
{
Name: "prevPage",
Types: []string{"String"},
},
{
Name: "pageNavigation",
Types: []string{"Array"},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsSearchArgs{
hasNamespace: in.Has("namespace"),
hasModule: in.Has("module"),
hasQuery: in.Has("query"),
hasMeta: in.Has("meta"),
hasDeleted: in.Has("deleted"),
hasSort: in.Has("sort"),
hasLimit: in.Has("limit"),
hasIncTotal: in.Has("incTotal"),
hasIncPageNavigation: in.Has("incPageNavigation"),
hasPageCursor: in.Has("pageCursor"),
}
)
if err = in.Decode(args); err != nil {
return
}
// 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)
case h.reg.Type("ComposeNamespace").Type():
args.namespaceRes = aux.Get().(*types.Namespace)
}
}
// 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)
case h.reg.Type("ComposeModule").Type():
args.moduleRes = aux.Get().(*types.Module)
}
}
var results *recordsSearchResults
if results, err = h.search(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Records (*types.Record) to Array (of ComposeRecord)
var (
tval expr.TypedValue
tarr = make([]expr.TypedValue, len(results.Records))
)
for i := range results.Records {
if tarr[i], err = h.reg.Type("ComposeRecord").Cast(results.Records[i]); err != nil {
return
}
}
if tval, err = expr.NewArray(tarr); err != nil {
return
} else if err = expr.Assign(out, "records", tval); err != nil {
return
}
}
{
// converting results.Total (uint64) to UnsignedInteger
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("UnsignedInteger").Cast(results.Total); err != nil {
return
} else if err = expr.Assign(out, "total", tval); err != nil {
return
}
}
{
// converting results.NextPage (string) to String
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("String").Cast(results.NextPage); err != nil {
return
} else if err = expr.Assign(out, "nextPage", tval); err != nil {
return
}
}
{
// converting results.PrevPage (string) to String
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("String").Cast(results.PrevPage); err != nil {
return
} else if err = expr.Assign(out, "prevPage", tval); err != nil {
return
}
}
{
// converting results.PageNavigation ([]expr.TypedValue) to Array
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("Array").Cast(results.PageNavigation); err != nil {
return
} else if err = expr.Assign(out, "pageNavigation", tval); err != nil {
return
}
}
return
},
}
}
type (
recordsFirstArgs struct {
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
namespaceRes *types.Namespace
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
moduleRes *types.Module
}
recordsFirstResults struct {
Record *types.Record
}
)
func (a recordsFirstArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
}
func (a recordsFirstArgs) GetModule() (bool, uint64, string, *types.Module) {
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
}
// First function Compose record lookup (oldest)
//
// expects implementation of first function:
//
// func (h recordsHandler) first(ctx context.Context, args *recordsFirstArgs) (results *recordsFirstResults, err error) {
// return
// }
func (h recordsHandler) First() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsFirst",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose record lookup (oldest)",
},
Parameters: []*atypes.Param{
{
Name: "namespace",
Types: []string{"ID", "Handle", "ComposeNamespace"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "module",
Types: []string{"ID", "Handle", "ComposeModule"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Module",
Description: "Even with unique record ID across all modules, module needs to be known\nbefore doing any record operations. Mainly because records of different\nmodules can be located in different stores.",
},
},
},
Results: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsFirstArgs{
hasNamespace: in.Has("namespace"),
hasModule: in.Has("module"),
}
)
if err = in.Decode(args); err != nil {
return
}
// 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)
case h.reg.Type("ComposeNamespace").Type():
args.namespaceRes = aux.Get().(*types.Namespace)
}
}
// 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)
case h.reg.Type("ComposeModule").Type():
args.moduleRes = aux.Get().(*types.Module)
}
}
var results *recordsFirstResults
if results, err = h.first(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Record (*types.Record) to ComposeRecord
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("ComposeRecord").Cast(results.Record); err != nil {
return
} else if err = expr.Assign(out, "record", tval); err != nil {
return
}
}
return
},
}
}
type (
recordsLastArgs struct {
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
namespaceRes *types.Namespace
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
moduleRes *types.Module
}
recordsLastResults struct {
Record *types.Record
}
)
func (a recordsLastArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
}
func (a recordsLastArgs) GetModule() (bool, uint64, string, *types.Module) {
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
}
// Last function Compose record lookup (newest)
//
// expects implementation of last function:
//
// func (h recordsHandler) last(ctx context.Context, args *recordsLastArgs) (results *recordsLastResults, err error) {
// return
// }
func (h recordsHandler) Last() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsLast",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose record lookup (newest)",
},
Parameters: []*atypes.Param{
{
Name: "namespace",
Types: []string{"ID", "Handle", "ComposeNamespace"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "module",
Types: []string{"ID", "Handle", "ComposeModule"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Module",
Description: "Even with unique record ID across all modules, module needs to be known\nbefore doing any record operations. Mainly because records of different\nmodules can be located in different stores.",
},
},
},
Results: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsLastArgs{
hasNamespace: in.Has("namespace"),
hasModule: in.Has("module"),
}
)
if err = in.Decode(args); err != nil {
return
}
// 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)
case h.reg.Type("ComposeNamespace").Type():
args.namespaceRes = aux.Get().(*types.Namespace)
}
}
// 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)
case h.reg.Type("ComposeModule").Type():
args.moduleRes = aux.Get().(*types.Module)
}
}
var results *recordsLastResults
if results, err = h.last(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Record (*types.Record) to ComposeRecord
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("ComposeRecord").Cast(results.Record); err != nil {
return
} else if err = expr.Assign(out, "record", tval); err != nil {
return
}
}
return
},
}
}
type (
recordsEachArgs struct {
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
namespaceRes *types.Namespace
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
moduleRes *types.Module
hasQuery bool
Query string
hasMeta bool
Meta map[string]any
hasDeleted bool
Deleted uint64
hasSort bool
Sort string
hasLimit bool
Limit uint64
hasIncTotal bool
IncTotal bool
hasIncPageNavigation bool
IncPageNavigation bool
hasPageCursor bool
PageCursor string
}
recordsEachResults struct {
Record *types.Record
Index uint64
Total uint64
}
)
func (a recordsEachArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
}
func (a recordsEachArgs) GetModule() (bool, uint64, string, *types.Module) {
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
}
// Each function Compose records
//
// expects implementation of each function:
//
// func (h recordsHandler) each(ctx context.Context, args *recordsEachArgs) (results *recordsEachResults, err error) {
// return
// }
func (h recordsHandler) Each() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsEach",
Kind: "iterator",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose records",
},
Parameters: []*atypes.Param{
{
Name: "namespace",
Types: []string{"ID", "Handle", "ComposeNamespace"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "module",
Types: []string{"ID", "Handle", "ComposeModule"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Module",
Description: "Even with unique record ID across all modules, module needs to be known\nbefore doing any record operations. Mainly because records of different\nmodules can be located in different stores.",
},
},
{
Name: "query",
Types: []string{"String"},
Meta: &atypes.ParamMeta{
Label: "Query",
},
},
{
Name: "meta",
Types: []string{"Meta"},
Meta: &atypes.ParamMeta{
Label: "Meta",
},
},
{
Name: "deleted",
Types: []string{"UnsignedInteger"},
Meta: &atypes.ParamMeta{
Label: "Deleted",
},
},
{
Name: "sort",
Types: []string{"String"},
Meta: &atypes.ParamMeta{
Label: "Sort",
},
},
{
Name: "limit",
Types: []string{"UnsignedInteger"},
Meta: &atypes.ParamMeta{
Label: "Limit",
},
},
{
Name: "incTotal",
Types: []string{"Boolean"},
Meta: &atypes.ParamMeta{
Label: "Include total",
},
},
{
Name: "incPageNavigation",
Types: []string{"Boolean"},
Meta: &atypes.ParamMeta{
Label: "Include page navigation",
},
},
{
Name: "pageCursor",
Types: []string{"String"},
Meta: &atypes.ParamMeta{
Label: "Page cursor",
},
},
},
Results: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"},
},
{
Name: "index",
Types: []string{"UnsignedInteger"},
Meta: &atypes.ParamMeta{
Label: "Iteration counter",
Description: "Zero-based number iteration counter",
},
},
{
Name: "total",
Types: []string{"UnsignedInteger"},
Meta: &atypes.ParamMeta{
Label: "Total records found",
Description: "Total items that satisfy given conditions.\n\nNeeds to be explicitly requested with incTotal argument",
},
},
},
Iterator: func(ctx context.Context, in *expr.Vars) (out wfexec.IteratorHandler, err error) {
var (
args = &recordsEachArgs{
hasNamespace: in.Has("namespace"),
hasModule: in.Has("module"),
hasQuery: in.Has("query"),
hasMeta: in.Has("meta"),
hasDeleted: in.Has("deleted"),
hasSort: in.Has("sort"),
hasLimit: in.Has("limit"),
hasIncTotal: in.Has("incTotal"),
hasIncPageNavigation: in.Has("incPageNavigation"),
hasPageCursor: in.Has("pageCursor"),
}
)
if err = in.Decode(args); err != nil {
return
}
// 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)
case h.reg.Type("ComposeNamespace").Type():
args.namespaceRes = aux.Get().(*types.Namespace)
}
}
// 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)
case h.reg.Type("ComposeModule").Type():
args.moduleRes = aux.Get().(*types.Module)
}
}
return h.each(ctx, args)
},
}
}
type (
recordsNewArgs struct {
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
namespaceRes *types.Namespace
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
moduleRes *types.Module
}
recordsNewResults struct {
Record *types.Record
}
)
func (a recordsNewArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
}
func (a recordsNewArgs) GetModule() (bool, uint64, string, *types.Module) {
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
}
// New function Compose record maker
//
// expects implementation of new function:
//
// func (h recordsHandler) new(ctx context.Context, args *recordsNewArgs) (results *recordsNewResults, err error) {
// return
// }
func (h recordsHandler) New() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsNew",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose record maker",
Description: "Creates new compose record instance without saving it",
},
Parameters: []*atypes.Param{
{
Name: "namespace",
Types: []string{"ID", "Handle", "ComposeNamespace"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "module",
Types: []string{"ID", "Handle", "ComposeModule"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Module",
Description: "Even with unique record ID across all modules, module needs to be known\nbefore doing any record operations. Mainly because records of different\nmodules can be located in different stores.",
},
},
},
Results: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsNewArgs{
hasNamespace: in.Has("namespace"),
hasModule: in.Has("module"),
}
)
if err = in.Decode(args); err != nil {
return
}
// 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)
case h.reg.Type("ComposeNamespace").Type():
args.namespaceRes = aux.Get().(*types.Namespace)
}
}
// 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)
case h.reg.Type("ComposeModule").Type():
args.moduleRes = aux.Get().(*types.Module)
}
}
var results *recordsNewResults
if results, err = h.new(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Record (*types.Record) to ComposeRecord
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("ComposeRecord").Cast(results.Record); err != nil {
return
} else if err = expr.Assign(out, "record", tval); err != nil {
return
}
}
return
},
}
}
type (
recordsValidateArgs struct {
hasRecord bool
Record *types.Record
}
recordsValidateResults struct {
Valid bool
}
)
// Validate function Compose record validator
//
// expects implementation of validate function:
//
// func (h recordsHandler) validate(ctx context.Context, args *recordsValidateArgs) (results *recordsValidateResults, err error) {
// return
// }
func (h recordsHandler) Validate() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsValidate",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose record validator",
},
Parameters: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Record",
},
},
},
Results: []*atypes.Param{
{
Name: "valid",
Types: []string{"Boolean"},
Meta: &atypes.ParamMeta{
Label: "Set to true when record is valid",
},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsValidateArgs{
hasRecord: in.Has("record"),
}
)
if err = in.Decode(args); err != nil {
return
}
var results *recordsValidateResults
if results, err = h.validate(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Valid (bool) to Boolean
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("Boolean").Cast(results.Valid); err != nil {
return
} else if err = expr.Assign(out, "valid", tval); err != nil {
return
}
}
return
},
}
}
type (
recordsCreateArgs struct {
hasRecord bool
Record *types.Record
}
recordsCreateResults struct {
Record *types.Record
}
)
// Create function Compose record create
//
// expects implementation of create function:
//
// func (h recordsHandler) create(ctx context.Context, args *recordsCreateArgs) (results *recordsCreateResults, err error) {
// return
// }
func (h recordsHandler) Create() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsCreate",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "create": "step", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose record create",
},
Parameters: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Record",
},
},
},
Results: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsCreateArgs{
hasRecord: in.Has("record"),
}
)
if err = in.Decode(args); err != nil {
return
}
var results *recordsCreateResults
if results, err = h.create(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Record (*types.Record) to ComposeRecord
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("ComposeRecord").Cast(results.Record); err != nil {
return
} else if err = expr.Assign(out, "record", tval); err != nil {
return
}
}
return
},
}
}
type (
recordsUpdateArgs struct {
hasRecord bool
Record *types.Record
}
recordsUpdateResults struct {
Record *types.Record
}
)
// Update function Compose record update
//
// expects implementation of update function:
//
// func (h recordsHandler) update(ctx context.Context, args *recordsUpdateArgs) (results *recordsUpdateResults, err error) {
// return
// }
func (h recordsHandler) Update() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsUpdate",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow", "update": "step"},
Meta: &atypes.FunctionMeta{
Short: "Compose record update",
},
Parameters: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Record",
},
},
},
Results: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsUpdateArgs{
hasRecord: in.Has("record"),
}
)
if err = in.Decode(args); err != nil {
return
}
var results *recordsUpdateResults
if results, err = h.update(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Record (*types.Record) to ComposeRecord
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("ComposeRecord").Cast(results.Record); err != nil {
return
} else if err = expr.Assign(out, "record", tval); err != nil {
return
}
}
return
},
}
}
type (
recordsDeleteArgs struct {
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
moduleRes *types.Module
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
namespaceRes *types.Namespace
hasRecord bool
Record interface{}
recordID uint64
recordRes *types.Record
}
)
func (a recordsDeleteArgs) GetModule() (bool, uint64, string, *types.Module) {
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
}
func (a recordsDeleteArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
}
func (a recordsDeleteArgs) GetRecord() (bool, uint64, *types.Record) {
return a.hasRecord, a.recordID, a.recordRes
}
// Delete function Compose record delete
//
// expects implementation of delete function:
//
// func (h recordsHandler) delete(ctx context.Context, args *recordsDeleteArgs) (err error) {
// return
// }
func (h recordsHandler) Delete() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsDelete",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "delete": "step", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose record delete",
},
Parameters: []*atypes.Param{
{
Name: "module",
Types: []string{"ID", "Handle", "ComposeModule"},
Meta: &atypes.ParamMeta{
Label: "Module",
Description: "Even with unique record ID across all modules, module needs to be known\nbefore doing any record operations. Mainly because records of different\nmodules can be located in different stores.",
},
},
{
Name: "namespace",
Types: []string{"ID", "Handle", "ComposeNamespace"},
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "record",
Types: []string{"ID", "ComposeRecord"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Record",
},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsDeleteArgs{
hasModule: in.Has("module"),
hasNamespace: in.Has("namespace"),
hasRecord: in.Has("record"),
}
)
if err = in.Decode(args); err != nil {
return
}
// 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)
case h.reg.Type("ComposeModule").Type():
args.moduleRes = aux.Get().(*types.Module)
}
}
// 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)
case h.reg.Type("ComposeNamespace").Type():
args.namespaceRes = aux.Get().(*types.Namespace)
}
}
// Converting Record argument
if args.hasRecord {
aux := expr.Must(expr.Select(in, "record"))
switch aux.Type() {
case h.reg.Type("ID").Type():
args.recordID = aux.Get().(uint64)
case h.reg.Type("ComposeRecord").Type():
args.recordRes = aux.Get().(*types.Record)
}
}
return out, h.delete(ctx, args)
},
}
}
type (
recordsReportArgs struct {
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
namespaceRes *types.Namespace
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
moduleRes *types.Module
hasMetrics bool
Metrics string
hasDimensons bool
Dimensons string
hasFilter bool
Filter string
}
recordsReportResults struct {
Report interface{}
}
)
func (a recordsReportArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
}
func (a recordsReportArgs) GetModule() (bool, uint64, string, *types.Module) {
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
}
// Report function Report
//
// expects implementation of report function:
//
// func (h recordsHandler) report(ctx context.Context, args *recordsReportArgs) (results *recordsReportResults, err error) {
// return
// }
func (h recordsHandler) Report() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsReport",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Report",
Description: "Compose records report",
},
Parameters: []*atypes.Param{
{
Name: "namespace",
Types: []string{"ID", "Handle", "ComposeNamespace"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "module",
Types: []string{"ID", "Handle", "ComposeModule"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Module",
Description: "Even with unique record ID across all modules, module needs to be known\nbefore doing any record operations. Mainly because records of different\nmodules can be located in different stores.",
},
},
{
Name: "metrics",
Types: []string{"String"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Metrics for records report",
Description: "List of comma delimited expressions with aggregation functions (count, sum, min, avg)",
},
},
{
Name: "dimensons",
Types: []string{"String"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Dimensons for records report",
Description: "List of comma delimited dimension (i.e.: group by) expressions or fields",
},
},
{
Name: "filter",
Types: []string{"String"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Filter for records report",
Description: "Filter in CortezaQL format",
},
},
},
Results: []*atypes.Param{
{
Name: "report",
Types: []string{"Any"},
Meta: &atypes.ParamMeta{
Label: "Complex structure holding complete records report",
Description: "Example of a result value\n[]map[string]interface{}{\n\t{\"count\": 3, \"dimension_0\": 1, \"metric_0\": 3},\n\t{\"count\": 2, \"dimension_0\": 2, \"metric_0\": 5},\n\t{\"count\": 1, \"dimension_0\": nil, \"metric_0\": nil},\n}",
},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsReportArgs{
hasNamespace: in.Has("namespace"),
hasModule: in.Has("module"),
hasMetrics: in.Has("metrics"),
hasDimensons: in.Has("dimensons"),
hasFilter: in.Has("filter"),
}
)
if err = in.Decode(args); err != nil {
return
}
// 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)
case h.reg.Type("ComposeNamespace").Type():
args.namespaceRes = aux.Get().(*types.Namespace)
}
}
// 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)
case h.reg.Type("ComposeModule").Type():
args.moduleRes = aux.Get().(*types.Module)
}
}
var results *recordsReportResults
if results, err = h.report(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Report (interface{}) to Any
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("Any").Cast(results.Report); err != nil {
return
} else if err = expr.Assign(out, "report", tval); err != nil {
return
}
}
return
},
}
}
type (
recordsCloneArgs struct {
hasNamespace bool
Namespace interface{}
namespaceID uint64
namespaceHandle string
namespaceRes *types.Namespace
hasModule bool
Module interface{}
moduleID uint64
moduleHandle string
moduleRes *types.Module
hasRecord bool
Record interface{}
recordID uint64
recordRes *types.Record
}
recordsCloneResults struct {
Record *types.Record
}
)
func (a recordsCloneArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
}
func (a recordsCloneArgs) GetModule() (bool, uint64, string, *types.Module) {
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
}
func (a recordsCloneArgs) GetRecord() (bool, uint64, *types.Record) {
return a.hasRecord, a.recordID, a.recordRes
}
// Clone function Compose record cloner
//
// expects implementation of clone function:
//
// func (h recordsHandler) clone(ctx context.Context, args *recordsCloneArgs) (results *recordsCloneResults, err error) {
// return
// }
func (h recordsHandler) Clone() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsClone",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Compose record cloner",
Description: "Creates a copy of an existing record",
},
Parameters: []*atypes.Param{
{
Name: "namespace",
Types: []string{"ID", "Handle", "ComposeNamespace"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Namespace",
},
},
{
Name: "module",
Types: []string{"ID", "Handle", "ComposeModule"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Module",
Description: "Even with unique record ID across all modules, module needs to be known\nbefore doing any record operations. Mainly because records of different\nmodules can be located in different stores.",
},
},
{
Name: "record",
Types: []string{"ID", "ComposeRecord"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Record",
},
},
},
Results: []*atypes.Param{
{
Name: "record",
Types: []string{"ComposeRecord"},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &recordsCloneArgs{
hasNamespace: in.Has("namespace"),
hasModule: in.Has("module"),
hasRecord: in.Has("record"),
}
)
if err = in.Decode(args); err != nil {
return
}
// 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)
case h.reg.Type("ComposeNamespace").Type():
args.namespaceRes = aux.Get().(*types.Namespace)
}
}
// 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)
case h.reg.Type("ComposeModule").Type():
args.moduleRes = aux.Get().(*types.Module)
}
}
// Converting Record argument
if args.hasRecord {
aux := expr.Must(expr.Select(in, "record"))
switch aux.Type() {
case h.reg.Type("ID").Type():
args.recordID = aux.Get().(uint64)
case h.reg.Type("ComposeRecord").Type():
args.recordRes = aux.Get().(*types.Record)
}
}
var results *recordsCloneResults
if results, err = h.clone(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.Record (*types.Record) to ComposeRecord
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("ComposeRecord").Cast(results.Record); err != nil {
return
} else if err = expr.Assign(out, "record", tval); err != nil {
return
}
}
return
},
}
}