Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow definition #236

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions docs/flow-definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
enum EDataType {
PRIMITIVE, //number, boolean, text
TYPE,
OBJECT,
DATATYPE,
ARRAY,
GENERIC,
NODE
}

enum EDataTypeRuleType {
REGEX,
NUMBER_RANGE,
ITEM_OF_COLLECTION,
CONTAINS_TYPE,
CONTAINS_KEY,
//etc
}

interface Translation {
code: string //de_DE
text: string
}

interface DataTypeRule {
type: EDataTypeRuleType
config: object
}

interface DataType {
name: Translation[]
type: EDataType
rules?: DataTypeRule[]
inputTypes?: DataType[]
returnType?: DataType
parent?: DataType
}


interface RuntimeFunctionDefinition {
runtime_id: string
parameters?: RuntimeParameterDefinition[]
return_type?: DataType
}


interface RuntimeParameterDefinition {
type: DataType
name: string
nicosammito marked this conversation as resolved.
Show resolved Hide resolved
}


interface FunctionDefinition {
runtime_function: RuntimeFunctionDefinition
return_type?: DataType
parameters?: ParameterDefinition[]
name: Translation
nicosammito marked this conversation as resolved.
Show resolved Hide resolved
description: Translation

}

interface ParameterDefinition {
type: DataType
name: Translation // overrides the runtime parameter name and ref to language entry
nicosammito marked this conversation as resolved.
Show resolved Hide resolved
description: Translation
default_value: object
}

interface FlowType {
name: Translation
definition: FlowDefinition
}

interface FlowDefinition {
settings: FlowDefinitionSetting[]
}

interface FlowDefinitionSetting {
name: Translation
description: Translation
nicosammito marked this conversation as resolved.
Show resolved Hide resolved
type: DataType
default_value: object
}

interface Flow {
type: FlowType //in the actual implementation we will just link the name or id
settings: FlowSetting[]
starting_node: Node
}

interface FlowSetting {
definition: FlowDefinitionSetting
value: object
}

interface Node {
function: FunctionDefinition
parameters?: Parameter[]
next_node?: Node
}

interface Parameter {
definition: ParameterDefinition
value?: object
sub_node?: Node
}

const userObject: DataType = {
name: [{
code: "en_US",
text: "User"
}],
type: EDataType.OBJECT,
rules: [{
type: EDataTypeRuleType.CONTAINS_KEY,
config: {name: "firstname", type: "text", required: true}
}, {
type: EDataTypeRuleType.CONTAINS_KEY,
config: {name: "lastname", type: "text"}
}, {
type: EDataTypeRuleType.CONTAINS_KEY,
config: {name: "email", type: "text"}
}, {
type: EDataTypeRuleType.CONTAINS_KEY,
config: {name: "age", type: "PositiveNumber"}
}]

}

const integerArrayType: DataType = {
name: [{
code: "en_US",
text: "IntegerArray"
}],
type: EDataType.ARRAY,
rules: [{
type: EDataTypeRuleType.CONTAINS_TYPE,
config: {type: "Number"}
}]
}


const forLoopFunctionParameterType: DataType = {
name: [{
code: "en_US",
text: "Function"
}],
type: EDataType.NODE,
inputTypes: [{
name: [{
code: "en_US",
text: "item"
}],
type: EDataType.GENERIC
}]
}
Loading