From 92a47121e951f7dbce20649fa074833a373dba67 Mon Sep 17 00:00:00 2001 From: nicosammito Date: Thu, 14 Nov 2024 21:54:15 +0100 Subject: [PATCH] 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 + }] +}