contract

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: BSD-3-Clause Imports: 20 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

func ToSnakeCase(str string) string

ToSnakeCase converts camel case string to snake case

func WriteAppConfig

func WriteAppConfig(config *app.Config, outFile string) error

WriteAppConfig serializes an app config and its resources

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

type Components struct {
	Schemas map[string]*Schema `json:"schemas"`
}

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

func (*Contract) ToTrigger

func (c *Contract) ToTrigger(fe bool) (*trigger.Config, error)

ToTrigger converts contract transactions to trigger handlers

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

func ReadContract(contractFile string) (*Spec, error)

ReadContract reads a contract file and returns the contract spec

func (*Spec) ConvertAppSchemas

func (s *Spec) ConvertAppSchemas() error

ConvertAppSchemas converts schemas in contract spec to Flogo schema def

func (*Spec) ToAppConfig

func (s *Spec) ToAppConfig(fe bool) (*app.Config, error)

ToAppConfig converts the first contract in a contract spec to a Flogo App Config

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

Jump to

Keyboard shortcuts

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