Documentation ¶
Index ¶
- func ExpandRef(def interface{}) (bool, error)
- func ExtractFlowSchema(schemadef interface{}) schema.Schema
- func GetAppSchemas() (map[string]*schema.Def, error)
- func ParametersToSchema(params []*Parameter) map[string]interface{}
- func ReadAppConfig(configFile string) (*app.Config, map[string]*definition.DefinitionRep, error)
- func SetAppResources(config *app.Config, resources map[string]*definition.DefinitionRep)
- func ToSnakeCase(str string) string
- func WriteAppConfig(config *app.Config, outFile string) error
- type Action
- type Components
- type Condition
- type Contract
- type FlowSchema
- type Info
- type Input
- type Parameter
- type Rule
- type Schema
- type Spec
- type Transaction
- func (tx *Transaction) ContainsParameter(name string) bool
- func (tx *Transaction) ParameterDef() (string, error)
- func (tx *Transaction) ToHandler(fe bool) (*trigger.HandlerConfig, error)
- func (tx *Transaction) ToHandlerSchema() (*trigger.SchemaConfig, error)
- func (tx *Transaction) ToResource(schm *trigger.SchemaConfig, cid string) (string, *definition.DefinitionRep, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandRef ¶ added in v0.1.4
ExpandRef expand schema ref, returns true if some refs are replaced
func ExtractFlowSchema ¶ added in v0.1.4
ExtractFlowSchema create serializable schema for a flow for a given schema def to work around FE import issue, the schema def is changed as follows:
for object, export only properties of the object for array, create app schema, and export a ref
func GetAppSchemas ¶ added in v0.1.4
GetAppSchemas construct and return Flogo app schema defs
func ParametersToSchema ¶ added in v0.1.4
ParametersToSchema convert transaction parameters to schema def
func ReadAppConfig ¶
func ReadAppConfig(configFile string) (*app.Config, map[string]*definition.DefinitionRep, error)
ReadAppConfig reads a Flogo app json file and returns app.Config
func SetAppResources ¶ added in v0.1.2
func SetAppResources(config *app.Config, resources map[string]*definition.DefinitionRep)
SetAppResources serialize flow resources and add them to app config
func ToSnakeCase ¶
ToSnakeCase converts camel case string to snake case
Types ¶
type Action ¶
type Action struct { Activity string `json:"activity"` Description string `json:"description,omitempty"` Name string `json:"name,omitempty"` Ledger map[string]interface{} `json:"ledger,omitempty"` Config map[string]interface{} `json:"config,omitempty"` Input *Input `json:"input,omitempty"` }
Action defines an activity for processing a transaction
type Components ¶
Components contains reusable schema definitions
type Condition ¶
type Condition struct { Name string `json:"name,omitempty"` Description string `json:"description"` Prerequisite string `json:"prerequisite,omitempty"` Expr string `json:"expr,omitempty"` }
Condition defines condition for executing list of actions for a transaction
type Contract ¶
type Contract struct { Name string `json:"name"` CID string `json:"cid"` Transactions []*Transaction `json:"transactions"` Info *Info `json:"info,omitempty"` }
Contract defines a smart contract
type FlowSchema ¶ added in v0.1.4
FlowSchema implements schema.Schema, used for flow metadata
func (*FlowSchema) MarshalJSON ¶ added in v0.1.4
func (f *FlowSchema) MarshalJSON() ([]byte, error)
MarshalJSON customize JSON marshalling
func (*FlowSchema) Type ¶ added in v0.1.4
func (f *FlowSchema) Type() string
Type implement schema.Schema interface
func (*FlowSchema) Validate ¶ added in v0.1.4
func (f *FlowSchema) Validate(data interface{}) error
Validate implement schema.Schema interface
func (*FlowSchema) Value ¶ added in v0.1.4
func (f *FlowSchema) Value() string
Value implement schema.Schema interface
type Info ¶
type Info struct { Title string `json:"title"` Version string `json:"version"` Description string `json:"description,omitempty"` }
Info defines general metadata of a contract spec
type Input ¶
type Input struct { Schema map[string]interface{} `json:"schema,omitempty"` Sample map[string]interface{} `json:"sample,omitempty"` Mapping map[string]interface{} `json:"mapping"` }
Input defines schema and mapping of an activity input
type Parameter ¶
type Parameter struct { Name string `json:"name"` Schema map[string]interface{} `json:"schema"` Description string `json:"description,omitempty"` Required bool `json:"required,omitempty"` }
Parameter defines a parameter of transaction
type Rule ¶
type Rule struct { Description string `json:"description,omitempty"` Condition *Condition `json:"condition,omitempty"` Actions []*Action `json:"actions"` }
Rule defines condition and actions for processing a transaction
type Schema ¶
type Schema struct { ID string `json:"$id"` Properties map[string]interface{} `json:"properties"` Required []string `json:"required,omitempty"` }
Schema defines reusable JSON schema
type Spec ¶
type Spec struct { Info *Info `json:"info"` Imports []string `json:"imports"` Contracts map[string]*Contract `json:"contracts"` Components *Components `json:"components"` }
Spec specifies one or more smart contracts
func ReadContract ¶
ReadContract reads a contract file and returns the contract spec
func (*Spec) ConvertAppSchemas ¶
ConvertAppSchemas converts schemas in contract spec to Flogo schema def
type Transaction ¶
type Transaction struct { Name string `json:"name"` Tag []string `json:"tag,omitempty"` Parameters []*Parameter `json:"parameters"` Transient map[string]interface{} `json:"transient"` Returns map[string]interface{} `json:"returns"` Rules []*Rule `json:"rules"` }
Transaction defines a transaction in a contract
func (*Transaction) ContainsParameter ¶
func (tx *Transaction) ContainsParameter(name string) bool
ContainsParameter returns true if a parameter matches the specified name
func (*Transaction) ParameterDef ¶
func (tx *Transaction) ParameterDef() (string, error)
ParameterDef returns comma-delimited string of transaction parameters
func (*Transaction) ToHandler ¶
func (tx *Transaction) ToHandler(fe bool) (*trigger.HandlerConfig, error)
ToHandler converts a contract transaction to trigger handler config
func (*Transaction) ToHandlerSchema ¶
func (tx *Transaction) ToHandlerSchema() (*trigger.SchemaConfig, error)
ToHandlerSchema extracts schema config from a contract transaction
func (*Transaction) ToResource ¶
func (tx *Transaction) ToResource(schm *trigger.SchemaConfig, cid string) (string, *definition.DefinitionRep, error)
ToResource converts a contract transaction to flow resource definition