legacy

package
v0.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2018 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextTopLevels = []string{"channel", "child", "contact", "date", "extra", "flow", "parent", "step"}

ContextTopLevels are the allowed top-level identifiers in legacy expressions, i.e. @contact.bar is valid but @foo.bar isn't

Functions

func MigrateTemplate

func MigrateTemplate(template string, extraAs ExtraVarsMapping) (string, error)

MigrateTemplate will take a legacy expression and translate it to the new syntax

func TransformTranslations

func TransformTranslations(items []map[utils.Language]string) map[utils.Language][]string

TransformTranslations transforms a list of single item translations into a map of multi-item translations, e.g.

[{"eng": "yes", "fra": "oui"}, {"eng": "no", "fra": "non"}] becomes {"eng": ["yes", "no"], "fra": ["oui", "non"]}

Types

type Action

type Action struct {
	Type string           `json:"type"`
	UUID flows.ActionUUID `json:"uuid"`
	Name string           `json:"name"`

	// message and email
	Msg          json.RawMessage `json:"msg"`
	Media        json.RawMessage `json:"media"`
	QuickReplies json.RawMessage `json:"quick_replies"`
	SendAll      bool            `json:"send_all"`

	// variable contact actions
	Contacts  []ContactReference  `json:"contacts"`
	Groups    []GroupReference    `json:"groups"`
	Variables []VariableReference `json:"variables"`

	// save actions
	Field string `json:"field"`
	Value string `json:"value"`
	Label string `json:"label"`

	// set language
	Language utils.Language `json:"lang"`

	// webhook
	Action         string          `json:"action"`
	Webhook        string          `json:"webhook"`
	WebhookHeaders []WebhookHeader `json:"webhook_headers"`

	// add lable action
	Labels []LabelReference `json:"labels"`

	// Start/Trigger flow
	Flow FlowReference `json:"flow"`

	// channel
	Channel flows.ChannelUUID `json:"channel"`

	//email
	Emails  []string `json:"emails"`
	Subject string   `json:"subject"`
}

type ActionSet

type ActionSet struct {
	Y           int            `json:"y"`
	X           int            `json:"x"`
	Destination flows.NodeUUID `json:"destination" validate:"omitempty,uuid4"`
	ExitUUID    flows.ExitUUID `json:"exit_uuid" validate:"required,uuid4"`
	UUID        flows.NodeUUID `json:"uuid" validate:"required,uuid4"`
	Actions     []Action       `json:"actions"`
}

type ContactReference

type ContactReference struct {
	UUID flows.ContactUUID `json:"uuid"`
}

func (*ContactReference) Migrate

func (c *ContactReference) Migrate() *flows.ContactReference

type ExtraVarsMapping

type ExtraVarsMapping int

ExtraVarsMapping defines how @extra.* variables should be migrated

const (
	ExtraAsWebhookJSON ExtraVarsMapping = iota
	ExtraAsTriggerParams
	ExtraAsFunction
)

different ways of mapping @extra in legacy flows

type Flow

type Flow struct {
	BaseLanguage utils.Language `json:"base_language"`
	Metadata     Metadata       `json:"metadata"`
	RuleSets     []RuleSet      `json:"rule_sets" validate:"dive"`
	ActionSets   []ActionSet    `json:"action_sets" validate:"dive"`
	Entry        flows.NodeUUID `json:"entry" validate:"required,uuid4"`
}

Flow is a flow in the legacy format

func ReadLegacyFlow

func ReadLegacyFlow(data json.RawMessage) (*Flow, error)

ReadLegacyFlow reads a single legacy formatted flow

func ReadLegacyFlows

func ReadLegacyFlows(data []json.RawMessage) ([]*Flow, error)

ReadLegacyFlows reads in legacy formatted flows

func (*Flow) Migrate

func (f *Flow) Migrate() (flows.Flow, error)

Migrate migrates this legacy flow to the new format

type FlowReference

type FlowReference struct {
	UUID flows.FlowUUID `json:"uuid"`
	Name string         `json:"name"`
}

func (*FlowReference) Migrate

func (f *FlowReference) Migrate() *flows.FlowReference

type GroupReference

type GroupReference struct {
	UUID flows.GroupUUID
	Name string
}

func (*GroupReference) Migrate

func (g *GroupReference) Migrate() *flows.GroupReference

func (*GroupReference) UnmarshalJSON

func (g *GroupReference) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a legacy group reference from the given JSON

type LabelReference

type LabelReference struct {
	UUID flows.LabelUUID
	Name string
}

func (*LabelReference) Migrate

func (l *LabelReference) Migrate() *flows.LabelReference

func (*LabelReference) UnmarshalJSON

func (l *LabelReference) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a legacy label reference from the given JSON

type Metadata

type Metadata struct {
	UUID    flows.FlowUUID `json:"uuid" validate:"required,uuid4"`
	Name    string         `json:"name"`
	Expires int            `json:"expires"`
}

Metadata is the metadata section of a legacy flow

type Rule

type Rule struct {
	UUID            flows.ExitUUID            `json:"uuid" validate:"required,uuid4"`
	Destination     flows.NodeUUID            `json:"destination" validate:"omitempty,uuid4"`
	DestinationType string                    `json:"destination_type" validate:"eq=A|eq=R"`
	Test            utils.TypedEnvelope       `json:"test"`
	Category        map[utils.Language]string `json:"category"`
}

type RuleSet

type RuleSet struct {
	Y       int             `json:"y"`
	X       int             `json:"x"`
	UUID    flows.NodeUUID  `json:"uuid" validate:"required,uuid4"`
	Type    string          `json:"ruleset_type"`
	Label   string          `json:"label"`
	Operand string          `json:"operand"`
	Rules   []Rule          `json:"rules"`
	Config  json.RawMessage `json:"config"`
}

type VariableReference

type VariableReference struct {
	ID string `json:"id"`
}

type WebhookConfig

type WebhookConfig struct {
	Webhook string          `json:"webhook"`
	Action  string          `json:"webhook_action"`
	Headers []WebhookHeader `json:"webhook_headers"`
}

type WebhookHeader

type WebhookHeader struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL