Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions package/mapper/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package/mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"access": "public"
},
"dependencies": {
"@code0-tech/sagittarius-graphql-types": "^0.0.0-56198dce107a9c09cc5eca0773f239d9c3eba598",
"@code0-tech/sagittarius-graphql-types": "^0.0.0-c63274fdd34593b8aa24f9f977659fd3d6270150",
"@code0-tech/tucana": "^0.0.44",
"@protobuf-ts/runtime": "^2.11.1",
"@protobuf-ts/runtime-rpc": "^2.11.1",
Expand Down
2 changes: 1 addition & 1 deletion package/mapper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {DefinitionMapper, Feature} from "./definition/mapper.js";
import * as fs from "node:fs";
import * as path from "node:path";

DefinitionMapper("../../definitions").then((value: Feature[]) => {
DefinitionMapper("../../../definitions").then((value: Feature[]) => {
const functions = value.flatMap(v => v.runtimeFunctions);
const types = value.flatMap(v => v.dataTypes);
const flows = value.flatMap(v => v.flowTypes);
Expand Down
24 changes: 22 additions & 2 deletions package/mapper/src/mapper/dataTypeMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,45 @@ import {getTranslationConnection} from "./translation.js";
import {Value} from "@code0-tech/tucana/pb/shared.struct_pb.js";

enum GenericCombinationStrategyType {
/** Represents a logical AND combination. */
And = 'AND',
/** Represents a logical OR combination. */
Or = 'OR'
}

enum DataTypeRulesVariant {
/** The rule checks if a key is present in the data type. */
ContainsKey = 'CONTAINS_KEY',
/** The rule checks if a specific type is present in the data type. */
ContainsType = 'CONTAINS_TYPE',
InputType = 'INPUT_TYPE',
/** The rule checks if the data type matches a specific input type. */
InputTypes = 'INPUT_TYPES',
/** The rule checks if an item is part of a collection in the data type. */
ItemOfCollection = 'ITEM_OF_COLLECTION',
/** The rule checks if a number falls within a specified range. */
NumberRange = 'NUMBER_RANGE',
/** The rule checks if the data type is a child of a specific parent type. */
ParentType = 'PARENT_TYPE',
/** The rule checks if a string matches a specified regular expression. */
Regex = 'REGEX',
/** The rule checks if the data type matches a specific return type. */
ReturnType = 'RETURN_TYPE'
}

enum DataTypeVariant {
/** Represents an array */
Array = 'ARRAY',
/** Represents an data type containing a data type */
DataType = 'DATA_TYPE',
/** Represents a error */
Error = 'ERROR',
/** Represents a node */
Node = 'NODE',
/** Represents an object */
Object = 'OBJECT',
/** Represents a primitive datatype */
Primitive = 'PRIMITIVE',
/** Represents a type */
Type = 'TYPE'
}

Expand All @@ -51,9 +68,12 @@ function getDataType(identifier: string, constructedDataTypes: ConstructedDataTy
return null
}
const constructed: DataType = {
__typename: "DataType",
id: `gid://sagittarius/DataType/${getID(constructedDataTypes)}`,
genericKeys: tucanaDataType.genericKeys,
identifier: tucanaDataType.identifier,
aliases: getTranslationConnection(tucanaDataType.alias),
displayMessages: getTranslationConnection(tucanaDataType.displayMessage),
name: getTranslationConnection(tucanaDataType.name),
rules: createRules(tucanaDataType.rules, constructedDataTypes),
variant: getDataTypeVariant(tucanaDataType.variant),
Expand Down Expand Up @@ -135,7 +155,7 @@ function createRules(rule: DefinitionDataTypeRule[], constructedDataTypes: Const
}),
}
const rule : DataTypeRule = {
variant: DataTypeRulesVariant.InputType,
variant: DataTypeRulesVariant.InputTypes,
config: ruleConfig
}
return rule;
Expand Down
8 changes: 6 additions & 2 deletions package/mapper/src/mapper/flowTypeMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,30 @@ import {ConstructedDataTypes, getID} from "../definition/mapper.js";

function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes): FlowType | null {
return {
id: `gid://sagittarius/TypesFlowType/${getID(constructed)}`,
__typename: "FlowType",
id: `gid://sagittarius/FlowType/${getID(constructed)}`,
identifier: flowType.identifier,
inputType: getDataType(flowType.inputTypeIdentifier!!, constructed),
returnType: getDataType(flowType.returnTypeIdentifier!!, constructed),
flowTypeSettings: createFlowTypeSetting(flowType.settings, constructed),
names: getTranslationConnection(flowType.name),
descriptions: getTranslationConnection(flowType.description),
aliases: getTranslationConnection(flowType.alias),
displayMessages: getTranslationConnection(flowType.displayMessage),
editable: flowType.editable
}
}

function createFlowTypeSetting(settings: TucanaFlowTypeSetting[], constructed: ConstructedDataTypes): FlowTypeSetting[] {
return settings.map(setting => {
const flowSetting: FlowTypeSetting = {
__typename: "FlowTypeSetting",
id: `gid://sagittarius/FlowTypeSetting/${getID(constructed)}`,
names: getTranslationConnection(setting.name),
descriptions: getTranslationConnection(setting.description),
dataType: getDataType(setting.dataTypeIdentifier, constructed),
identifier: setting.identifier,
unique: setting.unique
unique: setting.unique,
}

return flowSetting;
Expand Down
15 changes: 10 additions & 5 deletions package/mapper/src/mapper/functionMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@ import {ConstructedDataTypes, getID} from "../definition/mapper.js";
import {getTranslationConnection} from "./translation.js";

function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): FunctionDefinition | null {
return {
return {
__typename: "FunctionDefinition",
id: `gid://sagittarius/FunctionDefinition/${getID(constructed)}`,
genericKeys: func.genericKeys,
names: getTranslationConnection(func.name),
descriptions: getTranslationConnection(func.description),
documentations: getTranslationConnection(func.documentation),
deprecationMessages: getTranslationConnection(func.deprecationMessage),
identifier: func.runtimeName,
displayMessages: getTranslationConnection(func.displayMessage),
aliases: getTranslationConnection(func.alias),
throwsError: func.throwsError,
returnType: getDataTypeIdentifier(func.returnTypeIdentifier, constructed),
parameterDefinitions: getParameterDefinitionConnection(func.runtimeParameterDefinitions, constructed),
runtimeFunctionDefinition: {
id: `gid://sagittarius/RuntimeFunctionDefinition/${getID(constructed)}`,
identifier: func.runtimeName
}
runtimeFunctionDefinition: {
id: `gid://sagittarius/RuntimeFunctionDefinition/${getID(constructed)}`,
identifier: func.runtimeName
}
}
}

Expand All @@ -30,6 +34,7 @@ function getParameterDefinitionConnection(def: RuntimeParameterDefinition[], con
count: def.length,
nodes: def.map(node => {
return {
__typename: "ParameterDefinition",
id: `gid://sagittarius/ParameterDefinition/${getID(constructed)}`,
names: getTranslationConnection(node.name),
identifier: node.runtimeName,
Expand Down