legacy

package
v0.304.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPossibleDefinition added in v0.56.1

func IsPossibleDefinition(data []byte) bool

IsPossibleDefinition peeks at the given flow definition to determine if it could be in legacy format

func MigrateDefinition

func MigrateDefinition(data []byte, baseMediaURL string) ([]byte, error)

MigrateDefinition migrates a legacy definition to 13.0.0

func TransformTranslations

func TransformTranslations(items []Translations) map[i18n.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"]}

func URLJoin

func URLJoin(base, relative string) string

URLJoin joins two URL parts with /

Types

type Action

type Action struct {
	Type string     `json:"type"`
	UUID uuids.UUID `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 i18n.Language `json:"lang"`

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

	// start/trigger flow
	Flow FlowReference `json:"flow"`

	// channel
	Channel uuids.UUID `json:"channel"`

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

	// IVR
	Recording json.RawMessage `json:"recording"`
	URL       string          `json:"url"`
}

type ActionSet

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

type ContactReference

type ContactReference struct {
	UUID uuids.UUID `json:"uuid"`
	Name string     `json:"name"`
}

type Flow

type Flow struct {
	BaseLanguage i18n.Language `json:"base_language"`
	FlowType     string        `json:"flow_type"`
	RuleSets     []RuleSet     `json:"rule_sets" validate:"dive"`
	ActionSets   []ActionSet   `json:"action_sets" validate:"dive"`
	Entry        uuids.UUID    `json:"entry" validate:"omitempty,uuid"`
	Metadata     *Metadata     `json:"metadata"`

	// some flows have these set here instead of in metadata
	UUID uuids.UUID `json:"uuid"`
	Name string     `json:"name"`
}

Flow is a flow in the legacy format

func (*Flow) Migrate

func (f *Flow) Migrate(baseMediaURL string) ([]byte, error)

Migrate migrates this legacy flow to the new format

type FlowReference

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

type GroupReference

type GroupReference struct {
	UUID uuids.UUID
	Name string
}

func (*GroupReference) Migrate

func (g *GroupReference) Migrate() *assets.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 uuids.UUID
	Name string
}

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     uuids.UUID `json:"uuid"`
	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 NodeUI

type NodeUI struct {
	Type     UINodeType   `json:"type,omitempty"`
	Position Position     `json:"position"`
	Config   NodeUIConfig `json:"config,omitempty"`
}

NodeUI is a node specific UI configuration

func NewNodeUI

func NewNodeUI(nodeType UINodeType, x, y int, config NodeUIConfig) *NodeUI

NewNodeUI creates a new node specific UI configuration

type NodeUIConfig

type NodeUIConfig map[string]any

NodeUIConfig holds node type specific configuration

func (NodeUIConfig) AddCaseConfig

func (c NodeUIConfig) AddCaseConfig(uuid uuids.UUID, config map[string]any)

AddCaseConfig adds a case specific UI configuration

type Note

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

func (n *Note) Migrate() Sticky

Migrate migrates this note to a new sticky note

type Position

type Position struct {
	Left int `json:"left"`
	Top  int `json:"top"`
}

Position is a position of a node in the editor canvas

type Rule

type Rule struct {
	UUID            uuids.UUID    `json:"uuid" validate:"required,uuid"`
	Destination     uuids.UUID    `json:"destination" validate:"omitempty,uuid"`
	DestinationType string        `json:"destination_type" validate:"eq=A|eq=R"`
	Test            TypedEnvelope `json:"test"`
	Category        Translations  `json:"category"`
}

type RuleSet

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

type RulesetConfig

type RulesetConfig struct {
	Flow           *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

type Sticky struct {
	Position Position `json:"position"`
	Title    string   `json:"title"`
	Body     string   `json:"body"`
	Color    string   `json:"color"`
}

Sticky is a user note

type StringOrNumber

type StringOrNumber string

StringOrNumber represents something we need to read as a string, but might actually be number value in the JSON source

func (*StringOrNumber) UnmarshalJSON

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

UnmarshalJSON unmarshals this from the given JSON

type Translations

type Translations map[i18n.Language]string

Translations is an inline translation map used for localization

func ReadTranslations

func ReadTranslations(data []byte) (Translations, error)

ReadTranslations reads a translations map

func (Translations) Base

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

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

func (*Translations) UnmarshalJSON

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

UnmarshalJSON unmarshals legacy translations from the given JSON

type TypedEnvelope

type TypedEnvelope struct {
	Type string `json:"type" validate:"required"`
	Data []byte `json:"-"`
}

TypedEnvelope represents a json blob with a type property

func (*TypedEnvelope) UnmarshalJSON

func (e *TypedEnvelope) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a typed envelope from the given JSON

type UI

type UI struct {
	Nodes    map[uuids.UUID]*NodeUI `json:"nodes"`
	Stickies map[uuids.UUID]Sticky  `json:"stickies"`
}

UI is the _ui section of the flow definition used by the editor

func NewUI

func NewUI() *UI

NewUI creates a new UI section

func (*UI) AddNode

func (u *UI) AddNode(uuid uuids.UUID, nodeDetails *NodeUI)

AddNode adds information about a node

func (*UI) AddSticky

func (u *UI) AddSticky(sticky Sticky)

AddSticky adds a new sticky note

type UINodeType

type UINodeType string

UINodeType tells the editor how to render a particular node

const (
	UINodeTypeActionSet                 UINodeType = "execute_actions"
	UINodeTypeWaitForResponse           UINodeType = "wait_for_response"
	UINodeTypeSplitByAirtime            UINodeType = "split_by_airtime"
	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
⌂ 换网址