From 92a47121e951f7dbce20649fa074833a373dba67 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 14 Nov 2024 21:54:15 +0100 Subject: [PATCH 1/4] feat: added datatype definition --- docs/flow-definition.ts | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 docs/flow-definition.ts diff --git a/docs/flow-definition.ts b/docs/flow-definition.ts new file mode 100644 index 00000000..ac4e4b4b --- /dev/null +++ b/docs/flow-definition.ts @@ -0,0 +1,87 @@ +enum EDataType { + PRIMITIVE, //number, boolean, text + TYPE, + OBJECT, + DATATYPE, + ARRAY, + GENERIC, + FUNCTION +} + +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 +} + +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.FUNCTION, + inputTypes: [{ + name: [{ + code: "en_US", + text: "item" + }], + type: EDataType.GENERIC + }] +} From d37220d8cfa7e0c12515eb3e92bb7aa0fc6dab47 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Mon, 23 Dec 2024 01:35:00 +0100 Subject: [PATCH 2/4] feat: final flow definition --- docs/flow-definition.ts | 73 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/docs/flow-definition.ts b/docs/flow-definition.ts index ac4e4b4b..7f08feec 100644 --- a/docs/flow-definition.ts +++ b/docs/flow-definition.ts @@ -5,7 +5,7 @@ enum EDataType { DATATYPE, ARRAY, GENERIC, - FUNCTION + NODE } enum EDataTypeRuleType { @@ -36,6 +36,75 @@ interface DataType { parent?: DataType } + +interface RuntimeFunctionDefinition { + runtime_id: string + parameters?: RuntimeParameterDefinition[] + return_type?: DataType +} + + +interface RuntimeParameterDefinition { + type: DataType + name: string +} + + +interface FunctionDefinition { + runtime_function: RuntimeFunctionDefinition + return_type?: DataType + parameters?: ParameterDefinition[] + name: Translation + description: Translation + +} + +interface ParameterDefinition { + type: DataType + name: Translation // overrides the runtime parameter name and ref to language entry + description: Translation + default_value: object +} + +interface FlowType { + name: Translation + definition: FlowDefinition +} + +interface FlowDefinition { + settings: FlowDefinitionSetting[] +} + +interface FlowDefinitionSetting { + name: Translation + description: Translation + 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", @@ -76,7 +145,7 @@ const forLoopFunctionParameterType: DataType = { code: "en_US", text: "Function" }], - type: EDataType.FUNCTION, + type: EDataType.NODE, inputTypes: [{ name: [{ code: "en_US", From d1c2472f418501a866e1a9f24b9f39688d268918 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Sat, 28 Dec 2024 16:46:07 +0100 Subject: [PATCH 3/4] fix: adding docs support and multiply translations --- docs/flow-definition.ts | 63 +++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/docs/flow-definition.ts b/docs/flow-definition.ts index 7f08feec..1a347373 100644 --- a/docs/flow-definition.ts +++ b/docs/flow-definition.ts @@ -38,7 +38,7 @@ interface DataType { interface RuntimeFunctionDefinition { - runtime_id: string + runtime_id: string //standard::math::add parameters?: RuntimeParameterDefinition[] return_type?: DataType } @@ -54,20 +54,21 @@ interface FunctionDefinition { runtime_function: RuntimeFunctionDefinition return_type?: DataType parameters?: ParameterDefinition[] - name: Translation - description: Translation + name: Translation[] + description: Translation[] + documentation: Translation[] //as markdown } interface ParameterDefinition { type: DataType - name: Translation // overrides the runtime parameter name and ref to language entry - description: Translation - default_value: object + name: Translation[] // overrides the runtime parameter name and ref to language entry + description: Translation[] + default_value?: object } interface FlowType { - name: Translation + name: Translation[] definition: FlowDefinition } @@ -76,10 +77,10 @@ interface FlowDefinition { } interface FlowDefinitionSetting { - name: Translation - description: Translation + name: Translation[] + description: Translation[] type: DataType - default_value: object + default_value?: object } interface Flow { @@ -94,17 +95,19 @@ interface FlowSetting { } interface Node { - function: FunctionDefinition + function: Partial | string parameters?: Parameter[] next_node?: Node } interface Parameter { - definition: ParameterDefinition + definition: ParameterDefinition | string value?: object sub_node?: Node } + + const userObject: DataType = { name: [{ code: "en_US", @@ -154,3 +157,39 @@ const forLoopFunctionParameterType: DataType = { type: EDataType.GENERIC }] } + +const flow: Flow = { + + starting_node: { + function: "function::user::add", //-> standard::database::add + parameters: [{ + definition: "function::user::add__user", // -> standard::database::add_object + value: { + firstname: "Nico", + lastname: "Sammito", + email: "nico@sammito.de", + age: 20 + } + }] + } + + +} + +const flow1: Flow = { + + starting_node: { + function: "function::user::add", //-> standard::database::add + parameters: [{ + definition: "function::user::add__user", // -> standard::database::add_object + sub_node: { + function: "function::user::get", //-> standard::database::get + parameters: [{ + definition: "function::user::get__id", //-> standard::database::get_key + value: {id: 123456789} + }] + } + }] + } + +} From adf0effab70c6f48043dbb485d299420616e9308 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Sat, 28 Dec 2024 17:51:33 +0100 Subject: [PATCH 4/4] fix: errors inside example flow --- docs/flow-definition.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/flow-definition.ts b/docs/flow-definition.ts index 1a347373..1762a0a3 100644 --- a/docs/flow-definition.ts +++ b/docs/flow-definition.ts @@ -84,26 +84,26 @@ interface FlowDefinitionSetting { } interface Flow { - type: FlowType //in the actual implementation we will just link the name or id + type: FlowType | string //in the actual implementation we will just link the name or id settings: FlowSetting[] - starting_node: Node + starting_node: NodeFunction } interface FlowSetting { - definition: FlowDefinitionSetting + definition: FlowDefinitionSetting | string value: object } -interface Node { +interface NodeFunction { function: Partial | string parameters?: Parameter[] - next_node?: Node + next_node?: NodeFunction } interface Parameter { definition: ParameterDefinition | string value?: object - sub_node?: Node + sub_node?: NodeFunction } @@ -159,7 +159,11 @@ const forLoopFunctionParameterType: DataType = { } const flow: Flow = { - + type: "", + settings: [{ + definition: "", + value: {} + }], starting_node: { function: "function::user::add", //-> standard::database::add parameters: [{ @@ -177,7 +181,11 @@ const flow: Flow = { } const flow1: Flow = { - + type: "", + settings: [{ + definition: "", + value: {} + }], starting_node: { function: "function::user::add", //-> standard::database::add parameters: [{