legacy

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TransformTranslations

func TransformTranslations(items []Translations) 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"`
	Name string            `json:"name"`
}

func (*ContactReference) Migrate

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

type DecimalString added in v0.10.8

type DecimalString string

DecimalString represents a decimal value which may be provided as a string or floating point value

func (*DecimalString) UnmarshalJSON added in v0.10.8

func (s *DecimalString) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a decimal string from the given JSON

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:"omitempty,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 (*Flow) Migrate

func (f *Flow) Migrate(includeUI bool) (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"`
	Revision int            `json:"revision"`
	Expires  int            `json:"expires"`
	Notes    []Note         `json:"notes,omitempty"`
}

Metadata is the metadata section of a legacy flow

type Note added in v0.9.9

type Note struct {
	X     decimal.Decimal `json:"x"`
	Y     decimal.Decimal `json:"y"`
	Title string          `json:"title"`
	Body  string          `json:"body"`
}

Note is a legacy sticky note

func (*Note) Migrate added in v0.9.9

func (n *Note) Migrate() Sticky

Migrate migrates this note to a new sticky note

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        Translations        `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 RulesetConfig added in v0.10.20

type RulesetConfig struct {
	Flow           *flows.FlowReference `json:"flow"`
	FieldDelimiter string               `json:"field_delimiter"`
	FieldIndex     int                  `json:"field_index"`
	Webhook        string               `json:"webhook"`
	WebhookAction  string               `json:"webhook_action"`
	WebhookHeaders []WebhookHeader      `json:"webhook_headers"`
	Resthook       string               `json:"resthook"`
}

RulesetConfig holds the config dictionary for a legacy ruleset

type Sticky added in v0.9.9

type Sticky map[string]interface{}

Sticky is a migrated note

type Translations added in v0.10.8

type Translations map[utils.Language]string

Translations is an inline translation map used for localization

func (Translations) Base added in v0.10.8

func (t Translations) Base(baseLanguage utils.Language) string

Base looks up the translation in the given base language, or "base"

func (*Translations) UnmarshalJSON added in v0.10.8

func (t *Translations) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals legacy translations from the given JSON

type UI added in v0.10.20

type UI map[string]interface{}

UI is a optional section in a flow definition with editor specific information

func NewUI added in v0.10.20

func NewUI() UI

NewUI creates a new UI section

func (UI) AddNode added in v0.10.20

func (u UI) AddNode(uuid flows.NodeUUID, x, y int, uiType UINodeType)

AddNode adds information about a node

func (UI) AddSticky added in v0.10.20

func (u UI) AddSticky(sticky Sticky)

AddSticky adds a new sticky note

type UINodeType added in v0.10.20

type UINodeType string

UINodeType tells the editor how to render a particular node

const (
	UINodeTypeWaitForResponse           UINodeType = "wait_for_response"
	UINodeTypeSplitBySubflow            UINodeType = "split_by_subflow"
	UINodeTypeSplitByWebhook            UINodeType = "split_by_webhook"
	UINodeTypeSplitByResthook           UINodeType = "split_by_resthook"
	UINodeTypeSplitByGroups             UINodeType = "split_by_groups"
	UINodeTypeSplitByExpression         UINodeType = "split_by_expression"
	UINodeTypeSplitByContactField       UINodeType = "split_by_contact_field"
	UINodeTypeSplitByRunResult          UINodeType = "split_by_run_result"
	UINodeTypeSplitByRunResultDelimited UINodeType = "split_by_run_result_delimited"
	UINodeTypeSplitByRandom             UINodeType = "split_by_random"
)

the different node types supported by the editor

type VariableReference

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

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