From b10bb1263fa7daba558a74728cf6d6da57aa4184 Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Mon, 20 Oct 2025 20:11:08 +0200 Subject: [PATCH 01/20] dependencies: added tucana --- reader/ts/package-lock.json | 37 +++++++++++++++++++++++-------------- reader/ts/package.json | 5 ++++- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/reader/ts/package-lock.json b/reader/ts/package-lock.json index ecb728e..f7fa95f 100644 --- a/reader/ts/package-lock.json +++ b/reader/ts/package-lock.json @@ -7,32 +7,41 @@ "": { "name": "@code0-tech/definition-reader", "version": "0.0.0", + "dependencies": { + "@code0-tech/tucana": "^0.0.37" + }, "devDependencies": { - "@code0-tech/sagittarius-graphql-types": "^0.0.0-4b2e73eae302fe499001bf42fdb3a6bcc5be78aa ", + "@code0-tech/sagittarius-graphql-types": "^0.0.0-967667e8c736081887d32d99a5e2ab0445718798", "@types/node": "^24.1.0", "typescript": "^5.8.3" } }, "node_modules/@code0-tech/sagittarius-graphql-types": { - "version": "0.0.0-f91466f0f343596ad170e7e5c5316a70b072594d", - "resolved": "https://registry.npmjs.org/@code0-tech/sagittarius-graphql-types/-/sagittarius-graphql-types-0.0.0-f91466f0f343596ad170e7e5c5316a70b072594d.tgz", - "integrity": "sha512-vXnbsCw1n3KhWX0ZutKR9xmspEyg9/cZspSMPTPyD8sSTDcPooei1967GlsfpPKfsJGPLzrMKxMRUS/ANXlATg==", + "version": "0.0.0-967667e8c736081887d32d99a5e2ab0445718798", + "resolved": "https://registry.npmjs.org/@code0-tech/sagittarius-graphql-types/-/sagittarius-graphql-types-0.0.0-967667e8c736081887d32d99a5e2ab0445718798.tgz", + "integrity": "sha512-YZ3AcTfb3AOfUz7+4co0Jo5u1yaPDoW6KXweklxn1smaEvpNd/RbAoqrFEF9bXAtFG+wacqqBy72dCy7XyfpoA==", "dev": true }, + "node_modules/@code0-tech/tucana": { + "version": "0.0.37", + "resolved": "https://registry.npmjs.org/@code0-tech/tucana/-/tucana-0.0.37.tgz", + "integrity": "sha512-eluuVkN3z4sJ6W6j11VD0OEq/jZPG+kMGMDTr3mRaiHUxGt90lfsBlqyzfLBIUXV8Q4vYTh9G1HuhpGoyRSH1Q==", + "license": "Apache-2.0" + }, "node_modules/@types/node": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.3.0.tgz", - "integrity": "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==", + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.0.tgz", + "integrity": "sha512-MKNwXh3seSK8WurXF7erHPJ2AONmMwkI7zAMrXZDPIru8jRqkk6rGDBVbw4mLwfqA+ZZliiDPg05JQ3uW66tKQ==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~7.10.0" + "undici-types": "~7.16.0" } }, "node_modules/typescript": { - "version": "5.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz", - "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -44,9 +53,9 @@ } }, "node_modules/undici-types": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz", - "integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "dev": true, "license": "MIT" } diff --git a/reader/ts/package.json b/reader/ts/package.json index 8e0a379..9342565 100644 --- a/reader/ts/package.json +++ b/reader/ts/package.json @@ -17,7 +17,7 @@ "author": "", "license": "", "devDependencies": { - "@code0-tech/sagittarius-graphql-types": "^0.0.0-4b2e73eae302fe499001bf42fdb3a6bcc5be78aa ", + "@code0-tech/sagittarius-graphql-types": "^0.0.0-967667e8c736081887d32d99a5e2ab0445718798", "@types/node": "^24.1.0", "typescript": "^5.8.3" }, @@ -30,5 +30,8 @@ ], "publishConfig": { "access": "public" + }, + "dependencies": { + "@code0-tech/tucana": "^0.0.37" } } From dfdb81758f52fa834bf535bcffbfc031e1376b85 Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Mon, 20 Oct 2025 20:11:39 +0200 Subject: [PATCH 02/20] feat: wip started to work on mapper --- reader/ts/src/parser.ts | 230 ++++++++++++++++++++++++++++++++++++++-- reader/ts/src/types.ts | 4 +- 2 files changed, 225 insertions(+), 9 deletions(-) diff --git a/reader/ts/src/parser.ts b/reader/ts/src/parser.ts index 91c87a4..622747b 100644 --- a/reader/ts/src/parser.ts +++ b/reader/ts/src/parser.ts @@ -1,5 +1,22 @@ import {Reader} from './reader.js'; -import {DataType, FlowType, RuntimeFunctionDefinition} from "@code0-tech/sagittarius-graphql-types"; +import { + DataType, DataTypeIdentifier, + DataTypeRule, + DataTypeRuleConnection, DataTypeRulesConfig, + DataTypeRulesVariant, + DataTypeVariant, + FlowType, FlowTypeSetting, + FunctionDefinition, ParameterDefinitionConnection, + TranslationConnection +} from "@code0-tech/sagittarius-graphql-types"; +import { + DefinitionDataType, + DefinitionDataType_Variant, + DefinitionDataTypeRule +} from "@code0-tech/tucana/pb/shared.data_type_pb.js"; +import {Translation} from "@code0-tech/tucana/pb/shared.translation_pb.js" +import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.js" +import {RuntimeFunctionDefinition as TucanaFunction, RuntimeParameterDefinition} from "@code0-tech/tucana/pb/shared.runtime_function_pb.js" import {Feature, Meta, MetaType} from "./types.js"; export const Definition = (rootPath: string): Feature[] => { @@ -32,22 +49,221 @@ function appendMeta(feature: Feature, meta: Meta): void { try { switch (meta.type) { case MetaType.DataType: { - const parsed = JSON.parse(definition) as DataType; - feature.dataTypes.push(parsed); + const parsed = JSON.parse(definition) as DefinitionDataType; + const dataType: DataType = { + genericKeys: parsed.genericKeys, + identifier: parsed.identifier, + name: createTranslation(parsed.name), + rules: createRules(parsed.rules), + variant: getDataTypeVariant(parsed.variant) + } + feature.dataTypes.push(dataType); break; } case MetaType.FlowType: { - const parsed = JSON.parse(definition) as FlowType; - feature.flowTypes.push(parsed); + const parsed = JSON.parse(definition) as TucanaFlowType; + const flowType: FlowType = { + identifier: parsed.identifier, + inputType: getDataType(parsed.inputTypeIdentifier), + returnType: getDataType(parsed.returnTypeIdentifier), + flowTypeSettings: createFlowTypeSetting(parsed.settings), + names: createTranslation(parsed.name), + descriptions: createTranslation(parsed.description), + editable: parsed.editable + } + feature.flowTypes.push(flowType); break; } case MetaType.RuntimeFunction: { - const parsed = JSON.parse(definition) as RuntimeFunctionDefinition; - feature.runtimeFunctions.push(parsed); + const parsed = JSON.parse(definition) as TucanaFunction; + const functionDefinition: FunctionDefinition = { + genericKeys: parsed.genericKeys, + names: createTranslation(parsed.name), + descriptions: createTranslation(parsed.description), + documentations: createTranslation(parsed.documentation), + deprecationMessages: createTranslation(parsed.deprecationMessage), + throwsError: parsed.throwsError, + returnType: getDataTypeIdentifier(parsed.returnTypeIdentifier), + parameterDefinitions: getParameterDefinitionConnection(parsed.runtimeParameterDefinitions), + } + + feature.runtimeFunctions.push(functionDefinition); break; } } } catch (err: any) { console.error(`Error parsing ${meta.type} ${meta.name} ${definition}:`, err); } +} + +function createFlowTypeSetting(settings: TucanaFlowTypeSetting[]): FlowTypeSetting[] { + return settings.map(setting => { + return { + names: createTranslation(setting.name), + descriptions: createTranslation(setting.description), + dataType: getDataType(setting.dataTypeIdentifier), + identifier: setting.identifier, + unique: setting.unique + } + }) +} + +function getParameterDefinitionConnection(def: RuntimeParameterDefinition[]): ParameterDefinitionConnection { + return { + count: def.length, + nodes: def.map(node => { + return { + names: createTranslation(node.name), + descriptions: createTranslation(node.description), + documentations: createTranslation(node.documentation), + dataType: getDataTypeIdentifier(node.dataTypeIdentifier) + } + }) + } +} + +function getDataType(identifier: string | undefined): DataType { + // TODO + // @ts-ignore + return null +} + +function getDataTypeIdentifier(identifier: string): DataTypeIdentifier { + // TODO + // @ts-ignore + return null +} + +function createTranslation(translation: Translation[]): TranslationConnection { + return { + count: translation.length, + nodes: translation, + } +} + +function mapDefinitionRuleToDataTypeRule( + rule: DefinitionDataTypeRule +): DataTypeRulesConfig | null { + const { config } = rule; + + switch (config.oneofKind) { + case "containsKey": + return { + __typename: "DataTypeRulesContainsKeyConfig", + key: config.containsKey.key, + dataTypeIdentifier: config.containsKey.dataTypeIdentifier, + }; + + case "containsType": + return { + __typename: "DataTypeRulesContainsTypeConfig", + dataTypeIdentifier: config.containsType.dataTypeIdentifier, + }; + + case "itemOfCollection": + return { + __typename: "DataTypeRulesItemOfCollectionConfig", + items: config.itemOfCollection.items, + }; + + case "numberRange": + return { + __typename: "DataTypeRulesNumberRangeConfig", + from: Number(config.numberRange.from), + to: Number(config.numberRange.to), + steps: config.numberRange.steps ? Number(config.numberRange.steps) : undefined, + }; + + case "regex": + return { + __typename: "DataTypeRulesRegexConfig", + pattern: config.regex.pattern, + }; + + case "inputTypes": + return { + __typename: "DataTypeRulesInputTypesConfig", + inputTypes: config.inputTypes.inputTypes.map(input => ({ + __typename: "DataTypeRulesInputTypeConfig", + inputType: input.dataTypeIdentifier + ? { identifier: input.dataTypeIdentifier.type.dataTypeIdentifier ?? undefined } + : undefined, + dataTypeIdentifier: input.dataTypeIdentifier, + })), + }; + + case "returnType": + return { + __typename: "DataTypeRulesReturnTypeConfig", + dataTypeIdentifier: config.returnType.dataTypeIdentifier, + }; + + case "parentType": + return { + __typename: "DataTypeRulesParentTypeConfig", + dataTypeIdentifier: config.parentType.parentType, + }; + + default: + return null; + } +} + + +function createRules(rule: DefinitionDataTypeRule[]): DataTypeRuleConnection { + return { + count: rule.length, + nodes: rule.map(r => { + const rule: DataTypeRule = { + variant: getRuleTypeValue(r.config.oneofKind), + config: mapDefinitionRuleToDataTypeRule(r) + } + return rule; + } + ) + } +} + +function getRuleTypeValue(rule: string | unknown): DataTypeRulesVariant { + switch (rule) { + case "containsKey": + return DataTypeRulesVariant.ContainsKey; + case "containsType": + return DataTypeRulesVariant.ContainsType; + case "itemOfCollection": + return DataTypeRulesVariant.ItemOfCollection; + case "numberRange": + return DataTypeRulesVariant.NumberRange; + case "regex": + return DataTypeRulesVariant.Regex; + case "inputTypes": + return DataTypeRulesVariant.InputType; + case "returnType": + return DataTypeRulesVariant.ReturnType; + case "parentType": + return DataTypeRulesVariant.ParentType; + default: + throw new Error(`Unknown rule: ${rule}`); + } +} + +function getDataTypeVariant(variant: DefinitionDataType_Variant): DataTypeVariant { + switch (variant) { + case DefinitionDataType_Variant.ARRAY: + return DataTypeVariant.Array + case DefinitionDataType_Variant.DATATYPE: + return DataTypeVariant.DataType; + case DefinitionDataType_Variant.ERROR: + return DataTypeVariant.Error; + case DefinitionDataType_Variant.NODE: + return DataTypeVariant.Node; + case DefinitionDataType_Variant.OBJECT: + return DataTypeVariant.Object; + case DefinitionDataType_Variant.PRIMITIVE: + return DataTypeVariant.Primitive; + case DefinitionDataType_Variant.TYPE: + return DataTypeVariant.Type; + default: + throw new Error(`Unknown variant: ${variant}`); + } } \ No newline at end of file diff --git a/reader/ts/src/types.ts b/reader/ts/src/types.ts index a9bbc31..3a25b9e 100644 --- a/reader/ts/src/types.ts +++ b/reader/ts/src/types.ts @@ -1,4 +1,4 @@ -import {DataType, FlowType, RuntimeFunctionDefinition} from "@code0-tech/sagittarius-graphql-types"; +import {DataType, FlowType, FunctionDefinition} from "@code0-tech/sagittarius-graphql-types"; export enum MetaType { FlowType = 'FlowType', @@ -16,5 +16,5 @@ export interface Feature { name: string; dataTypes: DataType[]; flowTypes: FlowType[]; - runtimeFunctions: RuntimeFunctionDefinition[]; + runtimeFunctions: FunctionDefinition[]; } \ No newline at end of file From 6cb10496d38707f66663ae0640d7f16ff0d731f7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 21 Oct 2025 20:12:50 +0200 Subject: [PATCH 03/20] feat: wip mapper --- reader/ts/index.ts | 8 +- reader/ts/src/mapper/dataTypeMapper.ts | 154 +++++++++++++++ reader/ts/src/mapper/dataTypeSorter.ts | 115 +++++++++++ reader/ts/src/mapper/flowTypeMapper.ts | 36 ++++ reader/ts/src/mapper/functionMapper.ts | 42 ++++ reader/ts/src/mapper/helper.ts | 21 ++ reader/ts/src/parser.ts | 253 ++----------------------- reader/ts/src/reader.ts | 2 +- 8 files changed, 388 insertions(+), 243 deletions(-) create mode 100644 reader/ts/src/mapper/dataTypeMapper.ts create mode 100644 reader/ts/src/mapper/dataTypeSorter.ts create mode 100644 reader/ts/src/mapper/flowTypeMapper.ts create mode 100644 reader/ts/src/mapper/functionMapper.ts create mode 100644 reader/ts/src/mapper/helper.ts diff --git a/reader/ts/index.ts b/reader/ts/index.ts index 89a7fe1..63b2f96 100644 --- a/reader/ts/index.ts +++ b/reader/ts/index.ts @@ -1,2 +1,6 @@ -export { Definition } from './src/parser.js'; -export type { Feature, MetaType, Meta } from './src/types.js'; \ No newline at end of file +import {Definition} from "./src/parser.ts"; + +export { Definition } from './src/parser.ts'; +export type { Feature, MetaType, Meta } from './src/types.ts'; + +const def = Definition("../../definitions/") \ No newline at end of file diff --git a/reader/ts/src/mapper/dataTypeMapper.ts b/reader/ts/src/mapper/dataTypeMapper.ts new file mode 100644 index 0000000..ba35bc6 --- /dev/null +++ b/reader/ts/src/mapper/dataTypeMapper.ts @@ -0,0 +1,154 @@ +import { + DefinitionDataType, + DefinitionDataType_Variant, + DefinitionDataTypeRule +} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; +import {getTranslationConnection} from "./helper.ts"; +import { + DataType, + DataTypeRule, + DataTypeRuleConnection, DataTypeRulesContainsKeyConfig, + DataTypeRulesContainsTypeConfig, DataTypeRulesInputTypesConfig, DataTypeRulesItemOfCollectionConfig, + DataTypeRulesNumberRangeConfig, DataTypeRulesParentTypeConfig, DataTypeRulesRegexConfig, DataTypeRulesVariant, + DataTypeVariant +} from "@code0-tech/sagittarius-graphql-types"; + +function mapDataType(dataType: DefinitionDataType | undefined): DataType | null { + if (dataType == undefined) { + return null + } + + return { + genericKeys: dataType.genericKeys, + identifier: dataType.identifier, + name: getTranslationConnection(dataType.name), + rules: createRules(dataType.rules), + variant: getDataTypeVariant(dataType.variant) + } +} + +function createRules(rule: DefinitionDataTypeRule[]): DataTypeRuleConnection { + return { + count: rule.length, + nodes: rule.map(r => { + console.log(r) + const config: any = r.config + if (config.ContainsType) { + const ruleConfig: DataTypeRulesContainsTypeConfig = { + dataTypeIdentifier: null, //TODO + } + const rule: DataTypeRule = { + variant: DataTypeRulesVariant.ContainsType, + config: ruleConfig + } + return rule; + } + + if (config.ContainsKey) { + const ruleConfig: DataTypeRulesContainsKeyConfig = { + dataTypeIdentifier: null, //TODO + key: null, + } + const rule: DataTypeRule = { + variant: DataTypeRulesVariant.ContainsKey, + config: ruleConfig + } + return rule; + } + + if (config.ItemOfCollection) { + const ruleConfig: DataTypeRulesItemOfCollectionConfig = { + items: null, //TODO + } + const rule: DataTypeRule = { + variant: DataTypeRulesVariant.ItemOfCollection, + config: ruleConfig + } + return rule; + } + + if (config.NumberRange) { + const ruleConfig: DataTypeRulesNumberRangeConfig = { + from: null, //TODO + steps: null, //TODO + to: null, //TODO + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.NumberRange, + config: ruleConfig + } + return rule; + } + + if (config.Regex) { + const ruleConfig: DataTypeRulesRegexConfig = { + pattern: null, //TODO + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.Regex, + config: ruleConfig + } + return rule; + } + + if (config.InputTypes) { + const ruleConfig: DataTypeRulesInputTypesConfig = { + inputTypes: null, //TODO + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.InputType, + config: ruleConfig + } + return rule; + } + + if (config.ReturnType) { + const ruleConfig: DataTypeRulesParentTypeConfig = { + dataTypeIdentifier: null, //TODO + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.ReturnType, + config: ruleConfig + } + return rule; + } + + if (config.ParentType) { + const ruleConfig: DataTypeRulesParentTypeConfig = { + dataTypeIdentifier: null, //TODO + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.ParentType, + config: ruleConfig + } + return rule; + } + + throw new Error(`Unknown rule: ${rule}`) + } + ) + } +} + +function getDataTypeVariant(variant: DefinitionDataType_Variant): DataTypeVariant { + switch (variant) { + case DefinitionDataType_Variant.ARRAY: + return DataTypeVariant.Array + case DefinitionDataType_Variant.DATATYPE: + return DataTypeVariant.DataType; + case DefinitionDataType_Variant.ERROR: + return DataTypeVariant.Error; + case DefinitionDataType_Variant.NODE: + return DataTypeVariant.Node; + case DefinitionDataType_Variant.OBJECT: + return DataTypeVariant.Object; + case DefinitionDataType_Variant.PRIMITIVE: + return DataTypeVariant.Primitive; + case DefinitionDataType_Variant.TYPE: + return DataTypeVariant.Type; + default: + throw new Error(`Unknown variant: ${variant}`); + } +} + +export {mapDataType} \ No newline at end of file diff --git a/reader/ts/src/mapper/dataTypeSorter.ts b/reader/ts/src/mapper/dataTypeSorter.ts new file mode 100644 index 0000000..774e761 --- /dev/null +++ b/reader/ts/src/mapper/dataTypeSorter.ts @@ -0,0 +1,115 @@ +import { + DefinitionDataType, + DefinitionDataTypeRule +} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; +import {DataTypeIdentifier} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; + +function topologicalSort(items: { type: string; dependsOn: string[] }[]) { + const map = new Map(); + const visited = new Set(); + const visiting = new Set(); + const result: { type: string; dependsOn: string[] }[] = []; + + // Build a lookup map + for (const item of items) { + map.set(item.type, item); + } + + // Recursive DFS + function visit(type: string) { + if (visited.has(type)) return; + if (visiting.has(type)) { + throw new Error(`Cyclic dependency detected involving "${type}"`); + } + + visiting.add(type); + const item = map.get(type); + if (item) { + for (const dep of item.dependsOn) { + visit(dep); + } + result.push(item); + } + visiting.delete(type); + visited.add(type); + } + + // Visit all nodes + for (const item of items) { + visit(item.type); + } + + return result; +} + +function resolveDataTypeIdentifier(dataTypeIdentifier: DataTypeIdentifier | undefined): string[] { + const result: string[] = []; + + if (dataTypeIdentifier == undefined) { + return result + } + + const dataType: any = dataTypeIdentifier! + + if (dataType.type.GenericType) { + result.push(dataType.type.GenericType.data_type_identifier) + // @ts-ignore + dataType.type.GenericType.generic_mappers.forEach(mapper => { + // @ts-ignore + mapper.source.forEach(source => { + result.push(...resolveDataTypeIdentifier(source)) + }) + }) + return result + } + + if (dataType.type.DataTypeIdentifier) { + return [dataType.type.DataTypeIdentifier] + } + + return result; +} + +function getDependencies(rule: DefinitionDataTypeRule): string[] { + const config: any = rule.config; + if (config.ContainsType) { + const dataTypeIdentifier = config.ContainsType.data_type_identifier + return resolveDataTypeIdentifier(dataTypeIdentifier) + } + + if (config.InputTypes) { + // @ts-ignore + const dataTypes = config.InputTypes.input_types.map(input => input.data_type_identifier) + return dataTypes.map(resolveDataTypeIdentifier).flat() + } + + if (config.ParentType) { + return resolveDataTypeIdentifier(config.ParentType.parent_type) + } + + if (config.ReturnType) { + return resolveDataTypeIdentifier(config.ReturnType.data_type_identifier) + } + + return [] +} + +function sortDataTypes(types: DefinitionDataType[]) { + const identifiable = types.map(type => { + const dependencies = type.rules?.map(rule => getDependencies(rule)).flat() ?? [] + return { + type: type.identifier, + dependsOn: dependencies + } + }) + + const sorted = topologicalSort(identifiable) + + for (const item of sorted) { + console.log(item) + } + + return sorted.map(item => types.find(type => type.identifier === item.type)) +} + +export {sortDataTypes} \ No newline at end of file diff --git a/reader/ts/src/mapper/flowTypeMapper.ts b/reader/ts/src/mapper/flowTypeMapper.ts new file mode 100644 index 0000000..8983409 --- /dev/null +++ b/reader/ts/src/mapper/flowTypeMapper.ts @@ -0,0 +1,36 @@ +import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.ts" +import {FlowType, FlowTypeSetting} from "@code0-tech/sagittarius-graphql-types"; +import {getDataType, getTranslationConnection} from "./helper.ts"; +import {Meta, MetaType} from "../types.ts"; + +function mapFlowType(meta: Meta): FlowType | null { + if (meta.type != MetaType.FlowType) { + console.error(`Expected FlowType, got ${meta.type}`); + return null; + } + + const parsed = JSON.parse(meta.data) as TucanaFlowType; + return { + identifier: parsed.identifier, + inputType: getDataType(parsed.inputTypeIdentifier), + returnType: getDataType(parsed.returnTypeIdentifier), + flowTypeSettings: createFlowTypeSetting(parsed.settings), + names: getTranslationConnection(parsed.name), + descriptions: getTranslationConnection(parsed.description), + editable: parsed.editable + } +} + +function createFlowTypeSetting(settings: TucanaFlowTypeSetting[]): FlowTypeSetting[] { + return settings.map(setting => { + return { + names: getTranslationConnection(setting.name), + descriptions: getTranslationConnection(setting.description), + dataType: getDataType(setting.dataTypeIdentifier), + identifier: setting.identifier, + unique: setting.unique + } + }) +} + +export {mapFlowType} \ No newline at end of file diff --git a/reader/ts/src/mapper/functionMapper.ts b/reader/ts/src/mapper/functionMapper.ts new file mode 100644 index 0000000..b10afa2 --- /dev/null +++ b/reader/ts/src/mapper/functionMapper.ts @@ -0,0 +1,42 @@ +import {Meta, MetaType} from "../types.ts"; +import {FunctionDefinition, ParameterDefinitionConnection} from "@code0-tech/sagittarius-graphql-types"; +import { + RuntimeFunctionDefinition as TucanaFunction, + RuntimeParameterDefinition +} from "@code0-tech/tucana/pb/shared.runtime_function_pb.ts"; +import {getDataTypeIdentifier, getTranslationConnection} from "./helper.ts"; + +function mapFunction(meta:Meta): FunctionDefinition | null { + if (meta.type != MetaType.RuntimeFunction) { + console.error(`Expected RuntimeFunction, got ${meta.type}`); + return null; + } + + const parsed = JSON.parse(meta.data) as TucanaFunction; + return { + genericKeys: parsed.genericKeys, + names: getTranslationConnection(parsed.name), + descriptions: getTranslationConnection(parsed.description), + documentations: getTranslationConnection(parsed.documentation), + deprecationMessages: getTranslationConnection(parsed.deprecationMessage), + throwsError: parsed.throwsError, + returnType: getDataTypeIdentifier(parsed.returnTypeIdentifier), + parameterDefinitions: getParameterDefinitionConnection(parsed.runtimeParameterDefinitions), + } +} + +function getParameterDefinitionConnection(def: RuntimeParameterDefinition[]): ParameterDefinitionConnection { + return { + count: def.length, + nodes: def.map(node => { + return { + names: getTranslationConnection(node.name), + descriptions: getTranslationConnection(node.description), + documentations: getTranslationConnection(node.documentation), + dataType: getDataTypeIdentifier(node.dataTypeIdentifier) + } + }) + } +} + +export {mapFunction} \ No newline at end of file diff --git a/reader/ts/src/mapper/helper.ts b/reader/ts/src/mapper/helper.ts new file mode 100644 index 0000000..f3dcd79 --- /dev/null +++ b/reader/ts/src/mapper/helper.ts @@ -0,0 +1,21 @@ +import {DataType, DataTypeIdentifier, TranslationConnection} from "@code0-tech/sagittarius-graphql-types"; +import {Translation} from "@code0-tech/tucana/pb/shared.translation_pb.ts"; + +function getDataType(identifier: string | undefined): DataType { + // @ts-ignore + return null +} + +function getDataTypeIdentifier(identifier: string): DataTypeIdentifier { + // @ts-ignore + return null +} + +function getTranslationConnection(translation: Translation[]): TranslationConnection { + return { + count: translation.length, + nodes: translation, + } +} + +export {getDataType, getDataTypeIdentifier, getTranslationConnection} \ No newline at end of file diff --git a/reader/ts/src/parser.ts b/reader/ts/src/parser.ts index 622747b..a6a5869 100644 --- a/reader/ts/src/parser.ts +++ b/reader/ts/src/parser.ts @@ -1,29 +1,21 @@ -import {Reader} from './reader.js'; -import { - DataType, DataTypeIdentifier, - DataTypeRule, - DataTypeRuleConnection, DataTypeRulesConfig, - DataTypeRulesVariant, - DataTypeVariant, - FlowType, FlowTypeSetting, - FunctionDefinition, ParameterDefinitionConnection, - TranslationConnection -} from "@code0-tech/sagittarius-graphql-types"; -import { - DefinitionDataType, - DefinitionDataType_Variant, - DefinitionDataTypeRule -} from "@code0-tech/tucana/pb/shared.data_type_pb.js"; -import {Translation} from "@code0-tech/tucana/pb/shared.translation_pb.js" -import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.js" -import {RuntimeFunctionDefinition as TucanaFunction, RuntimeParameterDefinition} from "@code0-tech/tucana/pb/shared.runtime_function_pb.js" -import {Feature, Meta, MetaType} from "./types.js"; +import {Reader} from './reader.ts'; +import {DefinitionDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; +import {Feature, Meta, MetaType} from "./types.ts"; +import {sortDataTypes} from "./mapper/dataTypeSorter.ts"; +import {mapDataType} from "./mapper/dataTypeMapper.ts"; export const Definition = (rootPath: string): Feature[] => { const meta = Reader(rootPath); if (!meta) return []; const features: Feature[] = []; + const dt = meta.filter(m => m.type == MetaType.DataType).map(m => JSON.parse(m.data) as DefinitionDataType); + const sortedDt = sortDataTypes(dt).map(d => mapDataType(d)) + + for (const dt of sortedDt) { + console.log(dt) + } + for (const m of meta) { let feature = features.find((f) => f.name === m.name); @@ -44,226 +36,7 @@ export const Definition = (rootPath: string): Feature[] => { return features; } -function appendMeta(feature: Feature, meta: Meta): void { - const definition = meta.data; - try { - switch (meta.type) { - case MetaType.DataType: { - const parsed = JSON.parse(definition) as DefinitionDataType; - const dataType: DataType = { - genericKeys: parsed.genericKeys, - identifier: parsed.identifier, - name: createTranslation(parsed.name), - rules: createRules(parsed.rules), - variant: getDataTypeVariant(parsed.variant) - } - feature.dataTypes.push(dataType); - break; - } - case MetaType.FlowType: { - const parsed = JSON.parse(definition) as TucanaFlowType; - const flowType: FlowType = { - identifier: parsed.identifier, - inputType: getDataType(parsed.inputTypeIdentifier), - returnType: getDataType(parsed.returnTypeIdentifier), - flowTypeSettings: createFlowTypeSetting(parsed.settings), - names: createTranslation(parsed.name), - descriptions: createTranslation(parsed.description), - editable: parsed.editable - } - feature.flowTypes.push(flowType); - break; - } - case MetaType.RuntimeFunction: { - const parsed = JSON.parse(definition) as TucanaFunction; - const functionDefinition: FunctionDefinition = { - genericKeys: parsed.genericKeys, - names: createTranslation(parsed.name), - descriptions: createTranslation(parsed.description), - documentations: createTranslation(parsed.documentation), - deprecationMessages: createTranslation(parsed.deprecationMessage), - throwsError: parsed.throwsError, - returnType: getDataTypeIdentifier(parsed.returnTypeIdentifier), - parameterDefinitions: getParameterDefinitionConnection(parsed.runtimeParameterDefinitions), - } - feature.runtimeFunctions.push(functionDefinition); - break; - } - } - } catch (err: any) { - console.error(`Error parsing ${meta.type} ${meta.name} ${definition}:`, err); - } -} - -function createFlowTypeSetting(settings: TucanaFlowTypeSetting[]): FlowTypeSetting[] { - return settings.map(setting => { - return { - names: createTranslation(setting.name), - descriptions: createTranslation(setting.description), - dataType: getDataType(setting.dataTypeIdentifier), - identifier: setting.identifier, - unique: setting.unique - } - }) -} - -function getParameterDefinitionConnection(def: RuntimeParameterDefinition[]): ParameterDefinitionConnection { - return { - count: def.length, - nodes: def.map(node => { - return { - names: createTranslation(node.name), - descriptions: createTranslation(node.description), - documentations: createTranslation(node.documentation), - dataType: getDataTypeIdentifier(node.dataTypeIdentifier) - } - }) - } -} - -function getDataType(identifier: string | undefined): DataType { - // TODO - // @ts-ignore - return null -} - -function getDataTypeIdentifier(identifier: string): DataTypeIdentifier { - // TODO - // @ts-ignore - return null -} - -function createTranslation(translation: Translation[]): TranslationConnection { - return { - count: translation.length, - nodes: translation, - } -} - -function mapDefinitionRuleToDataTypeRule( - rule: DefinitionDataTypeRule -): DataTypeRulesConfig | null { - const { config } = rule; - - switch (config.oneofKind) { - case "containsKey": - return { - __typename: "DataTypeRulesContainsKeyConfig", - key: config.containsKey.key, - dataTypeIdentifier: config.containsKey.dataTypeIdentifier, - }; - - case "containsType": - return { - __typename: "DataTypeRulesContainsTypeConfig", - dataTypeIdentifier: config.containsType.dataTypeIdentifier, - }; - - case "itemOfCollection": - return { - __typename: "DataTypeRulesItemOfCollectionConfig", - items: config.itemOfCollection.items, - }; - - case "numberRange": - return { - __typename: "DataTypeRulesNumberRangeConfig", - from: Number(config.numberRange.from), - to: Number(config.numberRange.to), - steps: config.numberRange.steps ? Number(config.numberRange.steps) : undefined, - }; - - case "regex": - return { - __typename: "DataTypeRulesRegexConfig", - pattern: config.regex.pattern, - }; - - case "inputTypes": - return { - __typename: "DataTypeRulesInputTypesConfig", - inputTypes: config.inputTypes.inputTypes.map(input => ({ - __typename: "DataTypeRulesInputTypeConfig", - inputType: input.dataTypeIdentifier - ? { identifier: input.dataTypeIdentifier.type.dataTypeIdentifier ?? undefined } - : undefined, - dataTypeIdentifier: input.dataTypeIdentifier, - })), - }; - - case "returnType": - return { - __typename: "DataTypeRulesReturnTypeConfig", - dataTypeIdentifier: config.returnType.dataTypeIdentifier, - }; - - case "parentType": - return { - __typename: "DataTypeRulesParentTypeConfig", - dataTypeIdentifier: config.parentType.parentType, - }; - - default: - return null; - } -} - - -function createRules(rule: DefinitionDataTypeRule[]): DataTypeRuleConnection { - return { - count: rule.length, - nodes: rule.map(r => { - const rule: DataTypeRule = { - variant: getRuleTypeValue(r.config.oneofKind), - config: mapDefinitionRuleToDataTypeRule(r) - } - return rule; - } - ) - } -} - -function getRuleTypeValue(rule: string | unknown): DataTypeRulesVariant { - switch (rule) { - case "containsKey": - return DataTypeRulesVariant.ContainsKey; - case "containsType": - return DataTypeRulesVariant.ContainsType; - case "itemOfCollection": - return DataTypeRulesVariant.ItemOfCollection; - case "numberRange": - return DataTypeRulesVariant.NumberRange; - case "regex": - return DataTypeRulesVariant.Regex; - case "inputTypes": - return DataTypeRulesVariant.InputType; - case "returnType": - return DataTypeRulesVariant.ReturnType; - case "parentType": - return DataTypeRulesVariant.ParentType; - default: - throw new Error(`Unknown rule: ${rule}`); - } -} +function appendMeta(feature: Feature, meta: Meta): void { -function getDataTypeVariant(variant: DefinitionDataType_Variant): DataTypeVariant { - switch (variant) { - case DefinitionDataType_Variant.ARRAY: - return DataTypeVariant.Array - case DefinitionDataType_Variant.DATATYPE: - return DataTypeVariant.DataType; - case DefinitionDataType_Variant.ERROR: - return DataTypeVariant.Error; - case DefinitionDataType_Variant.NODE: - return DataTypeVariant.Node; - case DefinitionDataType_Variant.OBJECT: - return DataTypeVariant.Object; - case DefinitionDataType_Variant.PRIMITIVE: - return DataTypeVariant.Primitive; - case DefinitionDataType_Variant.TYPE: - return DataTypeVariant.Type; - default: - throw new Error(`Unknown variant: ${variant}`); - } } \ No newline at end of file diff --git a/reader/ts/src/reader.ts b/reader/ts/src/reader.ts index fe321ae..9d91650 100644 --- a/reader/ts/src/reader.ts +++ b/reader/ts/src/reader.ts @@ -1,6 +1,6 @@ import * as fs from 'fs'; import * as path from 'path'; -import {Meta, MetaType} from "./types.js"; +import {Meta, MetaType} from "./types.ts"; export const Reader = (rootPath: string): Meta[] => { const result: Meta[] = []; From 2bbc790ced360591642e527bb5a6c36d3eae17a5 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 21 Oct 2025 20:13:12 +0200 Subject: [PATCH 04/20] dependencies: added protobuf runtime --- reader/ts/package-lock.json | 14 ++++++++++---- reader/ts/package.json | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/reader/ts/package-lock.json b/reader/ts/package-lock.json index f7fa95f..12a2b4a 100644 --- a/reader/ts/package-lock.json +++ b/reader/ts/package-lock.json @@ -8,10 +8,11 @@ "name": "@code0-tech/definition-reader", "version": "0.0.0", "dependencies": { - "@code0-tech/tucana": "^0.0.37" + "@code0-tech/sagittarius-graphql-types": "^0.0.0-967667e8c736081887d32d99a5e2ab0445718798", + "@code0-tech/tucana": "^0.0.37", + "@protobuf-ts/runtime": "^2.11.1" }, "devDependencies": { - "@code0-tech/sagittarius-graphql-types": "^0.0.0-967667e8c736081887d32d99a5e2ab0445718798", "@types/node": "^24.1.0", "typescript": "^5.8.3" } @@ -19,8 +20,7 @@ "node_modules/@code0-tech/sagittarius-graphql-types": { "version": "0.0.0-967667e8c736081887d32d99a5e2ab0445718798", "resolved": "https://registry.npmjs.org/@code0-tech/sagittarius-graphql-types/-/sagittarius-graphql-types-0.0.0-967667e8c736081887d32d99a5e2ab0445718798.tgz", - "integrity": "sha512-YZ3AcTfb3AOfUz7+4co0Jo5u1yaPDoW6KXweklxn1smaEvpNd/RbAoqrFEF9bXAtFG+wacqqBy72dCy7XyfpoA==", - "dev": true + "integrity": "sha512-YZ3AcTfb3AOfUz7+4co0Jo5u1yaPDoW6KXweklxn1smaEvpNd/RbAoqrFEF9bXAtFG+wacqqBy72dCy7XyfpoA==" }, "node_modules/@code0-tech/tucana": { "version": "0.0.37", @@ -28,6 +28,12 @@ "integrity": "sha512-eluuVkN3z4sJ6W6j11VD0OEq/jZPG+kMGMDTr3mRaiHUxGt90lfsBlqyzfLBIUXV8Q4vYTh9G1HuhpGoyRSH1Q==", "license": "Apache-2.0" }, + "node_modules/@protobuf-ts/runtime": { + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@protobuf-ts/runtime/-/runtime-2.11.1.tgz", + "integrity": "sha512-KuDaT1IfHkugM2pyz+FwiY80ejWrkH1pAtOBOZFuR6SXEFTsnb/jiQWQ1rCIrcKx2BtyxnxW6BWwsVSA/Ie+WQ==", + "license": "(Apache-2.0 AND BSD-3-Clause)" + }, "node_modules/@types/node": { "version": "24.9.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.0.tgz", diff --git a/reader/ts/package.json b/reader/ts/package.json index 9342565..b8d443a 100644 --- a/reader/ts/package.json +++ b/reader/ts/package.json @@ -17,7 +17,6 @@ "author": "", "license": "", "devDependencies": { - "@code0-tech/sagittarius-graphql-types": "^0.0.0-967667e8c736081887d32d99a5e2ab0445718798", "@types/node": "^24.1.0", "typescript": "^5.8.3" }, @@ -32,6 +31,8 @@ "access": "public" }, "dependencies": { - "@code0-tech/tucana": "^0.0.37" + "@code0-tech/sagittarius-graphql-types": "^0.0.0-967667e8c736081887d32d99a5e2ab0445718798", + "@code0-tech/tucana": "^0.0.37", + "@protobuf-ts/runtime": "^2.11.1" } } From 0d2177e687fc679dbf599fb7e292bae73c4cb884 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 21 Oct 2025 20:13:20 +0200 Subject: [PATCH 05/20] feat: made tsc adjustments --- reader/ts/tsconfig.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reader/ts/tsconfig.json b/reader/ts/tsconfig.json index e2c781f..3f2c3b0 100644 --- a/reader/ts/tsconfig.json +++ b/reader/ts/tsconfig.json @@ -10,6 +10,9 @@ "strict": true, "moduleResolution": "nodenext", "declaration": true, - "emitDeclarationOnly": false + "emitDeclarationOnly": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "allowImportingTsExtensions": true, } } From f94166b46c149f97a4d7bb7d5f378e154191a2bf Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:34:50 +0200 Subject: [PATCH 06/20] fix: generic_key was empty --- .../standard/runtime_definition/array/std_array_index_of.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/definitions/standard/runtime_definition/array/std_array_index_of.json b/definitions/standard/runtime_definition/array/std_array_index_of.json index 2518a3e..eeb6ecc 100644 --- a/definitions/standard/runtime_definition/array/std_array_index_of.json +++ b/definitions/standard/runtime_definition/array/std_array_index_of.json @@ -45,7 +45,9 @@ }, { "data_type_identifier": { - "type": null + "type": { + "GenericKey": "R" + } }, "runtime_name": "item", "default_value": null, From 19698fbe61033354b5d88540998e11f91dc3e626 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:35:11 +0200 Subject: [PATCH 07/20] fix: added missing data_type_identifier in std_array_at.json --- .../standard/runtime_definition/array/std_array_at.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/definitions/standard/runtime_definition/array/std_array_at.json b/definitions/standard/runtime_definition/array/std_array_at.json index 46b50e3..d390d5c 100644 --- a/definitions/standard/runtime_definition/array/std_array_at.json +++ b/definitions/standard/runtime_definition/array/std_array_at.json @@ -45,7 +45,9 @@ }, { "data_type_identifier": { - "type": null + "type": { + "DataTypeIdentifier": "NUMBER" + } }, "runtime_name": "index", "default_value": null, @@ -70,7 +72,9 @@ } ], "return_type_identifier": { - "type": null + "type": { + "GenericKey": "R" + } }, "throws_error": false, "generic_keys": [ From 3c7b4bef4c88c9c09b357721452ebc2df2131189 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:36:14 +0200 Subject: [PATCH 08/20] dependencies: added protst --- Cargo.lock | 30 ++++++++++++++++++++++-------- Cargo.toml | 3 ++- cli/Cargo.toml | 1 + 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54844ab..062caf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -283,16 +283,17 @@ version = "0.0.0" dependencies = [ "bytes", "clap", - "code0-definition-reader 0.0.12", + "code0-definition-reader 0.0.13", "colored", "futures", "notify", + "prost", "reqwest", "serde", "serde_json", "tabled", "tokio", - "tucana", + "tucana 0.0.38", "zip", ] @@ -302,18 +303,18 @@ version = "0.0.0" dependencies = [ "serde", "serde_json", - "tucana", + "tucana 0.0.38", ] [[package]] name = "code0-definition-reader" -version = "0.0.12" +version = "0.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7b9d030a57501b5c6bcbd667c5241a69335421008b155b55145b4e66e9a325" +checksum = "85d08bd4aad0f928b9f9731f174055e65b12f05ae49aa4c8e7f8e7d8e1b92211" dependencies = [ "serde", "serde_json", - "tucana", + "tucana 0.0.37", ] [[package]] @@ -2158,9 +2159,22 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tucana" -version = "0.0.36" +version = "0.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0addd0c58b8b458ba668404246c428d4c71382f5a83d29ac69649f5c575bdfc4" +checksum = "bcbe6f5486fad0e31b4411c53b867d1c1b4748ce14561080417dec1ff8722f54" +dependencies = [ + "prost", + "prost-types", + "serde", + "serde_json", + "tonic", + "tonic-prost", + "tonic-prost-build", +] + +[[package]] +name = "tucana" +version = "0.0.38" dependencies = [ "prost", "prost-types", diff --git a/Cargo.toml b/Cargo.toml index 7ff5b07..a45641d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,4 +19,5 @@ tokio = "1.47.0" futures = "0.3.31" zip = "6.0.0" bytes = "1.10.1" -code0-definition-reader= "0.0.12" \ No newline at end of file +prost = "0.14.1" +code0-definition-reader= "0.0.13" \ No newline at end of file diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 9a7a128..95ccdd3 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -22,3 +22,4 @@ tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros"] } futures = { workspace = true } zip = { workspace = true } bytes = { workspace = true } +prost = {workspace = true} \ No newline at end of file From 62da7a87342f337555b882d77d01d2a61c527e61 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:36:48 +0200 Subject: [PATCH 09/20] feat: finished reader impl --- .gitignore | 4 +- reader/ts/index.ts | 5 +- reader/ts/src/mapper/dataTypeMapper.ts | 154 --------------- reader/ts/src/mapper/dataTypeSorter.ts | 1 - reader/ts/src/mapper/flowTypeMapper.ts | 28 ++- reader/ts/src/mapper/functionMapper.ts | 30 ++- reader/ts/src/mapper/helper.ts | 255 ++++++++++++++++++++++++- reader/ts/src/parser.ts | 76 ++++++-- reader/ts/src/reader.ts | 80 -------- reader/ts/src/types.ts | 12 -- 10 files changed, 338 insertions(+), 307 deletions(-) delete mode 100644 reader/ts/src/mapper/dataTypeMapper.ts delete mode 100644 reader/ts/src/reader.ts diff --git a/.gitignore b/.gitignore index 23de227..6796352 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ **/node_modules .idea reader/ts/src/*.js -reader/ts/build \ No newline at end of file +reader/ts/build +bundles +reader/**/*.js \ No newline at end of file diff --git a/reader/ts/index.ts b/reader/ts/index.ts index 63b2f96..c6d444a 100644 --- a/reader/ts/index.ts +++ b/reader/ts/index.ts @@ -1,6 +1,5 @@ import {Definition} from "./src/parser.ts"; export { Definition } from './src/parser.ts'; -export type { Feature, MetaType, Meta } from './src/types.ts'; - -const def = Definition("../../definitions/") \ No newline at end of file +export type { Feature } from './src/types.ts'; +Definition("../../cli/bundles") \ No newline at end of file diff --git a/reader/ts/src/mapper/dataTypeMapper.ts b/reader/ts/src/mapper/dataTypeMapper.ts deleted file mode 100644 index ba35bc6..0000000 --- a/reader/ts/src/mapper/dataTypeMapper.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { - DefinitionDataType, - DefinitionDataType_Variant, - DefinitionDataTypeRule -} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; -import {getTranslationConnection} from "./helper.ts"; -import { - DataType, - DataTypeRule, - DataTypeRuleConnection, DataTypeRulesContainsKeyConfig, - DataTypeRulesContainsTypeConfig, DataTypeRulesInputTypesConfig, DataTypeRulesItemOfCollectionConfig, - DataTypeRulesNumberRangeConfig, DataTypeRulesParentTypeConfig, DataTypeRulesRegexConfig, DataTypeRulesVariant, - DataTypeVariant -} from "@code0-tech/sagittarius-graphql-types"; - -function mapDataType(dataType: DefinitionDataType | undefined): DataType | null { - if (dataType == undefined) { - return null - } - - return { - genericKeys: dataType.genericKeys, - identifier: dataType.identifier, - name: getTranslationConnection(dataType.name), - rules: createRules(dataType.rules), - variant: getDataTypeVariant(dataType.variant) - } -} - -function createRules(rule: DefinitionDataTypeRule[]): DataTypeRuleConnection { - return { - count: rule.length, - nodes: rule.map(r => { - console.log(r) - const config: any = r.config - if (config.ContainsType) { - const ruleConfig: DataTypeRulesContainsTypeConfig = { - dataTypeIdentifier: null, //TODO - } - const rule: DataTypeRule = { - variant: DataTypeRulesVariant.ContainsType, - config: ruleConfig - } - return rule; - } - - if (config.ContainsKey) { - const ruleConfig: DataTypeRulesContainsKeyConfig = { - dataTypeIdentifier: null, //TODO - key: null, - } - const rule: DataTypeRule = { - variant: DataTypeRulesVariant.ContainsKey, - config: ruleConfig - } - return rule; - } - - if (config.ItemOfCollection) { - const ruleConfig: DataTypeRulesItemOfCollectionConfig = { - items: null, //TODO - } - const rule: DataTypeRule = { - variant: DataTypeRulesVariant.ItemOfCollection, - config: ruleConfig - } - return rule; - } - - if (config.NumberRange) { - const ruleConfig: DataTypeRulesNumberRangeConfig = { - from: null, //TODO - steps: null, //TODO - to: null, //TODO - } - const rule : DataTypeRule = { - variant: DataTypeRulesVariant.NumberRange, - config: ruleConfig - } - return rule; - } - - if (config.Regex) { - const ruleConfig: DataTypeRulesRegexConfig = { - pattern: null, //TODO - } - const rule : DataTypeRule = { - variant: DataTypeRulesVariant.Regex, - config: ruleConfig - } - return rule; - } - - if (config.InputTypes) { - const ruleConfig: DataTypeRulesInputTypesConfig = { - inputTypes: null, //TODO - } - const rule : DataTypeRule = { - variant: DataTypeRulesVariant.InputType, - config: ruleConfig - } - return rule; - } - - if (config.ReturnType) { - const ruleConfig: DataTypeRulesParentTypeConfig = { - dataTypeIdentifier: null, //TODO - } - const rule : DataTypeRule = { - variant: DataTypeRulesVariant.ReturnType, - config: ruleConfig - } - return rule; - } - - if (config.ParentType) { - const ruleConfig: DataTypeRulesParentTypeConfig = { - dataTypeIdentifier: null, //TODO - } - const rule : DataTypeRule = { - variant: DataTypeRulesVariant.ParentType, - config: ruleConfig - } - return rule; - } - - throw new Error(`Unknown rule: ${rule}`) - } - ) - } -} - -function getDataTypeVariant(variant: DefinitionDataType_Variant): DataTypeVariant { - switch (variant) { - case DefinitionDataType_Variant.ARRAY: - return DataTypeVariant.Array - case DefinitionDataType_Variant.DATATYPE: - return DataTypeVariant.DataType; - case DefinitionDataType_Variant.ERROR: - return DataTypeVariant.Error; - case DefinitionDataType_Variant.NODE: - return DataTypeVariant.Node; - case DefinitionDataType_Variant.OBJECT: - return DataTypeVariant.Object; - case DefinitionDataType_Variant.PRIMITIVE: - return DataTypeVariant.Primitive; - case DefinitionDataType_Variant.TYPE: - return DataTypeVariant.Type; - default: - throw new Error(`Unknown variant: ${variant}`); - } -} - -export {mapDataType} \ No newline at end of file diff --git a/reader/ts/src/mapper/dataTypeSorter.ts b/reader/ts/src/mapper/dataTypeSorter.ts index 774e761..e53a8c5 100644 --- a/reader/ts/src/mapper/dataTypeSorter.ts +++ b/reader/ts/src/mapper/dataTypeSorter.ts @@ -48,7 +48,6 @@ function resolveDataTypeIdentifier(dataTypeIdentifier: DataTypeIdentifier | unde if (dataTypeIdentifier == undefined) { return result } - const dataType: any = dataTypeIdentifier! if (dataType.type.GenericType) { diff --git a/reader/ts/src/mapper/flowTypeMapper.ts b/reader/ts/src/mapper/flowTypeMapper.ts index 8983409..c599190 100644 --- a/reader/ts/src/mapper/flowTypeMapper.ts +++ b/reader/ts/src/mapper/flowTypeMapper.ts @@ -1,32 +1,26 @@ import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.ts" import {FlowType, FlowTypeSetting} from "@code0-tech/sagittarius-graphql-types"; import {getDataType, getTranslationConnection} from "./helper.ts"; -import {Meta, MetaType} from "../types.ts"; +import {ConstructedDataTypes} from "../parser.ts"; -function mapFlowType(meta: Meta): FlowType | null { - if (meta.type != MetaType.FlowType) { - console.error(`Expected FlowType, got ${meta.type}`); - return null; - } - - const parsed = JSON.parse(meta.data) as TucanaFlowType; +function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes): FlowType | null { return { - identifier: parsed.identifier, - inputType: getDataType(parsed.inputTypeIdentifier), - returnType: getDataType(parsed.returnTypeIdentifier), - flowTypeSettings: createFlowTypeSetting(parsed.settings), - names: getTranslationConnection(parsed.name), - descriptions: getTranslationConnection(parsed.description), - editable: parsed.editable + 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), + editable: flowType.editable } } -function createFlowTypeSetting(settings: TucanaFlowTypeSetting[]): FlowTypeSetting[] { +function createFlowTypeSetting(settings: TucanaFlowTypeSetting[], constructed: ConstructedDataTypes): FlowTypeSetting[] { return settings.map(setting => { return { names: getTranslationConnection(setting.name), descriptions: getTranslationConnection(setting.description), - dataType: getDataType(setting.dataTypeIdentifier), + dataType: getDataType(setting.dataTypeIdentifier, constructed), identifier: setting.identifier, unique: setting.unique } diff --git a/reader/ts/src/mapper/functionMapper.ts b/reader/ts/src/mapper/functionMapper.ts index b10afa2..48dd0bc 100644 --- a/reader/ts/src/mapper/functionMapper.ts +++ b/reader/ts/src/mapper/functionMapper.ts @@ -1,31 +1,25 @@ -import {Meta, MetaType} from "../types.ts"; import {FunctionDefinition, ParameterDefinitionConnection} from "@code0-tech/sagittarius-graphql-types"; import { RuntimeFunctionDefinition as TucanaFunction, RuntimeParameterDefinition } from "@code0-tech/tucana/pb/shared.runtime_function_pb.ts"; import {getDataTypeIdentifier, getTranslationConnection} from "./helper.ts"; +import {ConstructedDataTypes} from "../parser.ts"; -function mapFunction(meta:Meta): FunctionDefinition | null { - if (meta.type != MetaType.RuntimeFunction) { - console.error(`Expected RuntimeFunction, got ${meta.type}`); - return null; - } - - const parsed = JSON.parse(meta.data) as TucanaFunction; +function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): FunctionDefinition | null { return { - genericKeys: parsed.genericKeys, - names: getTranslationConnection(parsed.name), - descriptions: getTranslationConnection(parsed.description), - documentations: getTranslationConnection(parsed.documentation), - deprecationMessages: getTranslationConnection(parsed.deprecationMessage), - throwsError: parsed.throwsError, - returnType: getDataTypeIdentifier(parsed.returnTypeIdentifier), - parameterDefinitions: getParameterDefinitionConnection(parsed.runtimeParameterDefinitions), + genericKeys: func.genericKeys, + names: getTranslationConnection(func.name), + descriptions: getTranslationConnection(func.description), + documentations: getTranslationConnection(func.documentation), + deprecationMessages: getTranslationConnection(func.deprecationMessage), + throwsError: func.throwsError, + returnType: getDataTypeIdentifier(func.returnTypeIdentifier, constructed), + parameterDefinitions: getParameterDefinitionConnection(func.runtimeParameterDefinitions, constructed), } } -function getParameterDefinitionConnection(def: RuntimeParameterDefinition[]): ParameterDefinitionConnection { +function getParameterDefinitionConnection(def: RuntimeParameterDefinition[], constructed: ConstructedDataTypes): ParameterDefinitionConnection { return { count: def.length, nodes: def.map(node => { @@ -33,7 +27,7 @@ function getParameterDefinitionConnection(def: RuntimeParameterDefinition[]): Pa names: getTranslationConnection(node.name), descriptions: getTranslationConnection(node.description), documentations: getTranslationConnection(node.documentation), - dataType: getDataTypeIdentifier(node.dataTypeIdentifier) + dataType: getDataTypeIdentifier(node.dataTypeIdentifier, constructed) } }) } diff --git a/reader/ts/src/mapper/helper.ts b/reader/ts/src/mapper/helper.ts index f3dcd79..3c66429 100644 --- a/reader/ts/src/mapper/helper.ts +++ b/reader/ts/src/mapper/helper.ts @@ -1,14 +1,255 @@ -import {DataType, DataTypeIdentifier, TranslationConnection} from "@code0-tech/sagittarius-graphql-types"; +import { + DataType, + DataTypeIdentifier, DataTypeRule, + DataTypeRuleConnection, DataTypeRulesContainsKeyConfig, DataTypeRulesContainsTypeConfig, + DataTypeRulesInputTypeConfig, + DataTypeRulesInputTypesConfig, + DataTypeRulesItemOfCollectionConfig, DataTypeRulesNumberRangeConfig, + DataTypeRulesParentTypeConfig, DataTypeRulesRegexConfig, GenericCombinationStrategy, + TranslationConnection +} from "@code0-tech/sagittarius-graphql-types"; import {Translation} from "@code0-tech/tucana/pb/shared.translation_pb.ts"; +import { + DataTypeIdentifier as TucanaDataTypeIdentifier, + DefinitionDataType_Variant, DefinitionDataTypeRule +} from "@code0-tech/tucana/pb/shared.data_type_pb.ts" +import {GenericMapper as TucanaGenericMapper} from "@code0-tech/tucana/pb/shared.data_type_pb.ts" +import {ConstructedDataTypes} from "../parser.js"; -function getDataType(identifier: string | undefined): DataType { - // @ts-ignore - return null +export enum GenericMapper_GenericCombinationStrategy { + UNKNOWN = 0, + AND = 1, + OR = 2 } -function getDataTypeIdentifier(identifier: string): DataTypeIdentifier { - // @ts-ignore - return null +export enum GenericCombinationStrategyType { + And = 'AND', + Or = 'OR' +} + +enum DataTypeVariant { + Array = 'ARRAY', + DataType = 'DATA_TYPE', + Error = 'ERROR', + Node = 'NODE', + Object = 'OBJECT', + Primitive = 'PRIMITIVE', + Type = 'TYPE' +} + +enum DataTypeRulesVariant { + ContainsKey = 'CONTAINS_KEY', + ContainsType = 'CONTAINS_TYPE', + InputType = 'INPUT_TYPE', + ItemOfCollection = 'ITEM_OF_COLLECTION', + NumberRange = 'NUMBER_RANGE', + ParentType = 'PARENT_TYPE', + Regex = 'REGEX', + ReturnType = 'RETURN_TYPE' +} + +function getDataType(identifier: string, constructedDataTypes: ConstructedDataTypes): DataType | null { + const dataType = constructedDataTypes.constructedDataTypes.find(dt => dt.identifier === identifier) + if (dataType == undefined) { + const tucanaDataType = constructedDataTypes.scannedTucanaTypes.find(dt => dt.identifier === identifier) + if (tucanaDataType == undefined) { + console.dir(constructedDataTypes, {depth: null}) + console.log("just skipping identifier") + console.log(identifier) + return null + } + const constructed = { + genericKeys: tucanaDataType.genericKeys, + identifier: tucanaDataType.identifier, + name: getTranslationConnection(tucanaDataType.name), + rules: createRules(tucanaDataType.rules, constructedDataTypes), + variant: getDataTypeVariant(tucanaDataType.variant), + } + + constructedDataTypes.constructedDataTypes.push(constructed) + return constructed; + } + return dataType; +} + +function createRules(rule: DefinitionDataTypeRule[], constructedDataTypes: ConstructedDataTypes) : DataTypeRuleConnection { + return { + count: rule.length, + nodes: rule.map(r => { + switch (r.config.oneofKind) { + case "containsType": { + const ruleConfig: DataTypeRulesContainsTypeConfig = { + dataTypeIdentifier: getDataTypeIdentifier(r.config.containsType.dataTypeIdentifier, constructedDataTypes), //TODO + } + const rule: DataTypeRule = { + variant: DataTypeRulesVariant.ContainsType, + config: ruleConfig + } + return rule; + } + case "containsKey": { + const ruleConfig: DataTypeRulesContainsKeyConfig = { + dataTypeIdentifier: getDataTypeIdentifier(r.config.containsKey.dataTypeIdentifier, constructedDataTypes), + key: r.config.containsKey.key, + } + const rule: DataTypeRule = { + variant: DataTypeRulesVariant.ContainsKey, + config: ruleConfig + } + return rule; + } + case "itemOfCollection": { + const ruleConfig: DataTypeRulesItemOfCollectionConfig = { + items: r.config.itemOfCollection.items, //TODO: This needs to be checked + } + const rule: DataTypeRule = { + variant: DataTypeRulesVariant.ItemOfCollection, + config: ruleConfig + } + return rule; + } + case "numberRange": { + const ruleConfig: DataTypeRulesNumberRangeConfig = { + from: Number(r.config.numberRange.from), + steps: r.config.numberRange.steps ? Number(r.config.numberRange.steps) : undefined, + to: Number(r.config.numberRange.to), + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.NumberRange, + config: ruleConfig + } + return rule; + } + case "regex": { + const ruleConfig: DataTypeRulesRegexConfig = { + pattern: r.config.regex.pattern, + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.Regex, + config: ruleConfig + } + return rule; + } + case "inputTypes": { + const ruleConfig: DataTypeRulesInputTypesConfig = { + inputTypes: r.config.inputTypes.inputTypes.map(i => { + console.log("AF: " + i.inputIdentifier) + const input: DataTypeRulesInputTypeConfig = { + dataTypeIdentifier: getDataTypeIdentifier(i.dataTypeIdentifier, constructedDataTypes), + inputType: null, //TODO (Later): This field is wrong in GraphQL => should be a string + } + return input; + }), + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.InputType, + config: ruleConfig + } + return rule; + } + + case "returnType": { + const ruleConfig: DataTypeRulesParentTypeConfig = { + dataTypeIdentifier: getDataTypeIdentifier(r.config.returnType.dataTypeIdentifier, constructedDataTypes), + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.ReturnType, + config: ruleConfig + } + return rule; + } + + case "parentType": { + const ruleConfig: DataTypeRulesParentTypeConfig = { + dataTypeIdentifier: getDataTypeIdentifier(r.config.parentType.parentType, constructedDataTypes), + } + const rule : DataTypeRule = { + variant: DataTypeRulesVariant.ParentType, + config: ruleConfig + } + return rule; + } + } + throw new Error(`Unknown rule: ${rule}`) + } + ) + } +} + +function getDataTypeVariant(variant: DefinitionDataType_Variant): DataTypeVariant { + switch (variant) { + case DefinitionDataType_Variant.ARRAY: + return DataTypeVariant.Array + case DefinitionDataType_Variant.DATATYPE: + return DataTypeVariant.DataType; + case DefinitionDataType_Variant.ERROR: + return DataTypeVariant.Error; + case DefinitionDataType_Variant.NODE: + return DataTypeVariant.Node; + case DefinitionDataType_Variant.OBJECT: + return DataTypeVariant.Object; + case DefinitionDataType_Variant.PRIMITIVE: + return DataTypeVariant.Primitive; + case DefinitionDataType_Variant.TYPE: + return DataTypeVariant.Type; + default: + throw new Error(`Unknown variant: ${variant}`); + } +} + +function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined, constructedDataTypes: ConstructedDataTypes): DataTypeIdentifier | null { + if (identifier == undefined) { + return null + } + + switch (identifier.type.oneofKind) { + case "genericType": { + return { + genericType: { + dataType: getDataType(identifier.type.genericType.dataTypeIdentifier, constructedDataTypes), + genericMappers: identifier.type.genericType.genericMappers.map((mapper: TucanaGenericMapper) => { + return { + genericCombinationStrategies: mapper.genericCombinations.map(m => { + let type = undefined + switch (m) { + case GenericMapper_GenericCombinationStrategy.AND: + type = GenericCombinationStrategyType.And + break + case GenericMapper_GenericCombinationStrategy.OR: + type = GenericCombinationStrategyType.Or + break + default: + throw new Error("GenericCombinationStrategy was Unknown"); + } + + return { + type: type + } + }), + sources: mapper.source.map(id => + getDataTypeIdentifier(id, constructedDataTypes) + ).filter(id => id != null), + target: mapper.target, + } + }), + } + } + } + + case "dataTypeIdentifier": { + return { + dataType: getDataType(identifier.type.dataTypeIdentifier, constructedDataTypes) + } + } + + case "genericKey": { + return { + genericKey: identifier.type.genericKey, + } + } + } + + return null; } function getTranslationConnection(translation: Translation[]): TranslationConnection { diff --git a/reader/ts/src/parser.ts b/reader/ts/src/parser.ts index a6a5869..4547762 100644 --- a/reader/ts/src/parser.ts +++ b/reader/ts/src/parser.ts @@ -1,15 +1,66 @@ -import {Reader} from './reader.ts'; +import {DefinitionDataType as TucanaDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; +import {Feature} from "./types.ts"; +import {readdirSync, readFileSync} from "node:fs"; +import {FlowType as TucanaFlowType} from "@code0-tech/tucana/pb/shared.flow_definition_pb.ts"; +import {RuntimeFunctionDefinition as TucanaFunction} from "@code0-tech/tucana/pb/shared.runtime_function_pb.ts"; +import path from "node:path"; +import {mapFlowType} from "./mapper/flowTypeMapper.ts"; +import {mapFunction} from "./mapper/functionMapper.ts"; +import {DataType, FlowType, FunctionDefinition} from "@code0-tech/sagittarius-graphql-types"; import {DefinitionDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; -import {Feature, Meta, MetaType} from "./types.ts"; -import {sortDataTypes} from "./mapper/dataTypeSorter.ts"; -import {mapDataType} from "./mapper/dataTypeMapper.ts"; +import {getDataType} from "./mapper/helper.ts"; -export const Definition = (rootPath: string): Feature[] => { - const meta = Reader(rootPath); - if (!meta) return []; - const features: Feature[] = []; +export interface ConstructedDataTypes { + scannedTucanaTypes: DefinitionDataType[] + constructedDataTypes: DataType[] +} + +export const Definition = (rootPath: string) => { + const dataTypes: TucanaDataType[] = [] + const runtimeFunctions: TucanaFunction[] = []; + const flowTypes: TucanaFlowType[] = []; + console.log(rootPath) + path.join() + readdirSync(rootPath, { withFileTypes: true }).forEach(file => { + console.log(file) + const filePath = path.join(file.parentPath, file.name) + console.log(filePath) + + const content = readFileSync(filePath); + if (file.name.includes("data_type")) { + const decoded = TucanaDataType.fromBinary(content); + dataTypes.push(decoded) + } + + if (file.name.includes("function")) { + const decoded = TucanaFunction.fromBinary(content); + runtimeFunctions.push(decoded) + } + + if (file.name.includes("flow_type")) { + const decoded = TucanaFlowType.fromBinary(content); + flowTypes.push(decoded) + } + }) + const constructed: ConstructedDataTypes = { + scannedTucanaTypes: dataTypes, + constructedDataTypes: [] + } + dataTypes.map(f => getDataType(f.identifier, constructed)).forEach((d: DataType | null) => console.dir(d, {depth: null})) + runtimeFunctions.map(f => mapFunction(f, constructed)).forEach((f: FunctionDefinition | null) => console.dir(f, {depth: null})) + flowTypes.map(f => mapFlowType(f, constructed)).forEach((f: FlowType | null) => console.dir(f, {depth: null})) - const dt = meta.filter(m => m.type == MetaType.DataType).map(m => JSON.parse(m.data) as DefinitionDataType); + //throw new Error("Not implemented") + /* + const dt = meta.filter(m => m.type == MetaType.DataType).map(m => { + // console.log(m.data) + // return DefinitionDataType.fromJsonString(m.data) + // console.dir(def, {depth: null}) + return null; + }); + for (const d of dt) { + // console.dir(d, {depth: null}) + } const sortedDt = sortDataTypes(dt).map(d => mapDataType(d)) for (const dt of sortedDt) { @@ -34,9 +85,6 @@ export const Definition = (rootPath: string): Feature[] => { } return features; -} - -function appendMeta(feature: Feature, meta: Meta): void { - -} \ No newline at end of file + */ +} diff --git a/reader/ts/src/reader.ts b/reader/ts/src/reader.ts deleted file mode 100644 index 9d91650..0000000 --- a/reader/ts/src/reader.ts +++ /dev/null @@ -1,80 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -import {Meta, MetaType} from "./types.ts"; - -export const Reader = (rootPath: string): Meta[] => { - const result: Meta[] = []; - - try { - const features = fs.readdirSync(rootPath, { withFileTypes: true }); - - for (const featureDirent of features) { - if (!featureDirent.isDirectory()) continue; - - const featurePath = path.join(rootPath, featureDirent.name); - const featureName = featureDirent.name; - - const typeDirs = fs.readdirSync(featurePath, { withFileTypes: true }); - - for (const typeDirent of typeDirs) { - if (!typeDirent.isDirectory()) continue; - - const metaType = matchMetaType(typeDirent.name); - if (!metaType) continue; - - const typePath = path.join(featurePath, typeDirent.name); - const definitions = fs.readdirSync(typePath, { withFileTypes: true }); - - for (const def of definitions) { - const defPath = path.join(typePath, def.name); - - if (def.isFile()) { - if (!defPath.endsWith('.json')) continue; - try { - const content = fs.readFileSync(defPath, 'utf-8'); - const meta: Meta = {name: featureName, type: metaType, data: content}; - result.push(meta); - } catch (err) { - console.error(`Error reading file: ${defPath}`, err); - } - } else if (def.isDirectory()) { - const subDefinitions = fs.readdirSync(defPath, { withFileTypes: true }); - - for (const subDef of subDefinitions) { - const subPath = path.join(defPath, subDef.name); - - if (!subPath.endsWith('.json')) continue; - if (!subDef.isFile()) continue; - - try { - const content = fs.readFileSync(subPath, 'utf-8'); - const meta: Meta = {name: featureName, type: metaType, data: content}; - result.push(meta); - } catch (err) { - console.error(`Error reading file: ${subPath}`, err); - } - } - } - } - } - } - - return result - } catch (err) { - console.error(`Error reading path ${rootPath}:`, err); - return []; - } -} - -function matchMetaType(name: string): MetaType | null { - switch (name) { - case 'flow_type': - return MetaType.FlowType; - case 'data_type': - return MetaType.DataType; - case 'runtime_definition': - return MetaType.RuntimeFunction; - default: - return null; - } -} diff --git a/reader/ts/src/types.ts b/reader/ts/src/types.ts index 3a25b9e..f68d5e8 100644 --- a/reader/ts/src/types.ts +++ b/reader/ts/src/types.ts @@ -1,17 +1,5 @@ import {DataType, FlowType, FunctionDefinition} from "@code0-tech/sagittarius-graphql-types"; -export enum MetaType { - FlowType = 'FlowType', - DataType = 'DataType', - RuntimeFunction = 'RuntimeFunction', -} - -export interface Meta { - name: string; - type: MetaType; - data: string; -} - export interface Feature { name: string; dataTypes: DataType[]; From 6d71b83a397f6f6a14055ce432ca667d5d21f344 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:37:10 +0200 Subject: [PATCH 10/20] dependencies: setup vite --- reader/ts/package-lock.json | 1047 ++++++++++++++++++++++++++++++++++- reader/ts/package.json | 5 +- reader/ts/tsconfig.json | 3 +- reader/ts/vite.config.ts | 14 + 4 files changed, 1065 insertions(+), 4 deletions(-) create mode 100644 reader/ts/vite.config.ts diff --git a/reader/ts/package-lock.json b/reader/ts/package-lock.json index 12a2b4a..f997296 100644 --- a/reader/ts/package-lock.json +++ b/reader/ts/package-lock.json @@ -14,7 +14,8 @@ }, "devDependencies": { "@types/node": "^24.1.0", - "typescript": "^5.8.3" + "typescript": "^5.8.3", + "vite": "^7.1.11" } }, "node_modules/@code0-tech/sagittarius-graphql-types": { @@ -28,12 +29,769 @@ "integrity": "sha512-eluuVkN3z4sJ6W6j11VD0OEq/jZPG+kMGMDTr3mRaiHUxGt90lfsBlqyzfLBIUXV8Q4vYTh9G1HuhpGoyRSH1Q==", "license": "Apache-2.0" }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.11.tgz", + "integrity": "sha512-Xt1dOL13m8u0WE8iplx9Ibbm+hFAO0GsU2P34UNoDGvZYkY8ifSiy6Zuc1lYxfG7svWE2fzqCUmFp5HCn51gJg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.11.tgz", + "integrity": "sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.11.tgz", + "integrity": "sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.11.tgz", + "integrity": "sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.11.tgz", + "integrity": "sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.11.tgz", + "integrity": "sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.11.tgz", + "integrity": "sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.11.tgz", + "integrity": "sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.11.tgz", + "integrity": "sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.11.tgz", + "integrity": "sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.11.tgz", + "integrity": "sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.11.tgz", + "integrity": "sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.11.tgz", + "integrity": "sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.11.tgz", + "integrity": "sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.11.tgz", + "integrity": "sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.11.tgz", + "integrity": "sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.11.tgz", + "integrity": "sha512-HSFAT4+WYjIhrHxKBwGmOOSpphjYkcswF449j6EjsjbinTZbp8PJtjsVK1XFJStdzXdy/jaddAep2FGY+wyFAQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.11.tgz", + "integrity": "sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.11.tgz", + "integrity": "sha512-u7tKA+qbzBydyj0vgpu+5h5AeudxOAGncb8N6C9Kh1N4n7wU1Xw1JDApsRjpShRpXRQlJLb9wY28ELpwdPcZ7A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.11.tgz", + "integrity": "sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.11.tgz", + "integrity": "sha512-CN+7c++kkbrckTOz5hrehxWN7uIhFFlmS/hqziSFVWpAzpWrQoAG4chH+nN3Be+Kzv/uuo7zhX716x3Sn2Jduw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.11.tgz", + "integrity": "sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.11.tgz", + "integrity": "sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.11.tgz", + "integrity": "sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.11.tgz", + "integrity": "sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.11.tgz", + "integrity": "sha512-D7Hpz6A2L4hzsRpPaCYkQnGOotdUpDzSGRIv9I+1ITdHROSFUWW95ZPZWQmGka1Fg7W3zFJowyn9WGwMJ0+KPA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@protobuf-ts/runtime": { "version": "2.11.1", "resolved": "https://registry.npmjs.org/@protobuf-ts/runtime/-/runtime-2.11.1.tgz", "integrity": "sha512-KuDaT1IfHkugM2pyz+FwiY80ejWrkH1pAtOBOZFuR6SXEFTsnb/jiQWQ1rCIrcKx2BtyxnxW6BWwsVSA/Ie+WQ==", "license": "(Apache-2.0 AND BSD-3-Clause)" }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.52.5.tgz", + "integrity": "sha512-8c1vW4ocv3UOMp9K+gToY5zL2XiiVw3k7f1ksf4yO1FlDFQ1C2u72iACFnSOceJFsWskc2WZNqeRhFRPzv+wtQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.52.5.tgz", + "integrity": "sha512-mQGfsIEFcu21mvqkEKKu2dYmtuSZOBMmAl5CFlPGLY94Vlcm+zWApK7F/eocsNzp8tKmbeBP8yXyAbx0XHsFNA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.52.5.tgz", + "integrity": "sha512-takF3CR71mCAGA+v794QUZ0b6ZSrgJkArC+gUiG6LB6TQty9T0Mqh3m2ImRBOxS2IeYBo4lKWIieSvnEk2OQWA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.52.5.tgz", + "integrity": "sha512-W901Pla8Ya95WpxDn//VF9K9u2JbocwV/v75TE0YIHNTbhqUTv9w4VuQ9MaWlNOkkEfFwkdNhXgcLqPSmHy0fA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.52.5.tgz", + "integrity": "sha512-QofO7i7JycsYOWxe0GFqhLmF6l1TqBswJMvICnRUjqCx8b47MTo46W8AoeQwiokAx3zVryVnxtBMcGcnX12LvA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.52.5.tgz", + "integrity": "sha512-jr21b/99ew8ujZubPo9skbrItHEIE50WdV86cdSoRkKtmWa+DDr6fu2c/xyRT0F/WazZpam6kk7IHBerSL7LDQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.52.5.tgz", + "integrity": "sha512-PsNAbcyv9CcecAUagQefwX8fQn9LQ4nZkpDboBOttmyffnInRy8R8dSg6hxxl2Re5QhHBf6FYIDhIj5v982ATQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.52.5.tgz", + "integrity": "sha512-Fw4tysRutyQc/wwkmcyoqFtJhh0u31K+Q6jYjeicsGJJ7bbEq8LwPWV/w0cnzOqR2m694/Af6hpFayLJZkG2VQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.52.5.tgz", + "integrity": "sha512-a+3wVnAYdQClOTlyapKmyI6BLPAFYs0JM8HRpgYZQO02rMR09ZcV9LbQB+NL6sljzG38869YqThrRnfPMCDtZg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.52.5.tgz", + "integrity": "sha512-AvttBOMwO9Pcuuf7m9PkC1PUIKsfaAJ4AYhy944qeTJgQOqJYJ9oVl2nYgY7Rk0mkbsuOpCAYSs6wLYB2Xiw0Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.52.5.tgz", + "integrity": "sha512-DkDk8pmXQV2wVrF6oq5tONK6UHLz/XcEVow4JTTerdeV1uqPeHxwcg7aFsfnSm9L+OO8WJsWotKM2JJPMWrQtA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.52.5.tgz", + "integrity": "sha512-W/b9ZN/U9+hPQVvlGwjzi+Wy4xdoH2I8EjaCkMvzpI7wJUs8sWJ03Rq96jRnHkSrcHTpQe8h5Tg3ZzUPGauvAw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.52.5.tgz", + "integrity": "sha512-sjQLr9BW7R/ZiXnQiWPkErNfLMkkWIoCz7YMn27HldKsADEKa5WYdobaa1hmN6slu9oWQbB6/jFpJ+P2IkVrmw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.52.5.tgz", + "integrity": "sha512-hq3jU/kGyjXWTvAh2awn8oHroCbrPm8JqM7RUpKjalIRWWXE01CQOf/tUNWNHjmbMHg/hmNCwc/Pz3k1T/j/Lg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.52.5.tgz", + "integrity": "sha512-gn8kHOrku8D4NGHMK1Y7NA7INQTRdVOntt1OCYypZPRt6skGbddska44K8iocdpxHTMMNui5oH4elPH4QOLrFQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.52.5.tgz", + "integrity": "sha512-hXGLYpdhiNElzN770+H2nlx+jRog8TyynpTVzdlc6bndktjKWyZyiCsuDAlpd+j+W+WNqfcyAWz9HxxIGfZm1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.52.5.tgz", + "integrity": "sha512-arCGIcuNKjBoKAXD+y7XomR9gY6Mw7HnFBv5Rw7wQRvwYLR7gBAgV7Mb2QTyjXfTveBNFAtPt46/36vV9STLNg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.52.5.tgz", + "integrity": "sha512-QoFqB6+/9Rly/RiPjaomPLmR/13cgkIGfA40LHly9zcH1S0bN2HVFYk3a1eAyHQyjs3ZJYlXvIGtcCs5tko9Cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.52.5.tgz", + "integrity": "sha512-w0cDWVR6MlTstla1cIfOGyl8+qb93FlAVutcor14Gf5Md5ap5ySfQ7R9S/NjNaMLSFdUnKGEasmVnu3lCMqB7w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.52.5.tgz", + "integrity": "sha512-Aufdpzp7DpOTULJCuvzqcItSGDH73pF3ko/f+ckJhxQyHtp67rHw3HMNxoIdDMUITJESNE6a8uh4Lo4SLouOUg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.52.5.tgz", + "integrity": "sha512-UGBUGPFp1vkj6p8wCRraqNhqwX/4kNQPS57BCFc8wYh0g94iVIW33wJtQAx3G7vrjjNtRaxiMUylM0ktp/TRSQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.52.5.tgz", + "integrity": "sha512-TAcgQh2sSkykPRWLrdyy2AiceMckNf5loITqXxFI5VuQjS5tSuw3WlwdN8qv8vzjLAUTvYaH/mVjSFpbkFbpTg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "24.9.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.0.tgz", @@ -44,6 +802,218 @@ "undici-types": "~7.16.0" } }, + "node_modules/esbuild": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.11.tgz", + "integrity": "sha512-KohQwyzrKTQmhXDW1PjCv3Tyspn9n5GcY2RTDqeORIdIJY8yKIF7sTSopFmn/wpMPW4rdPXI0UE5LJLuq3bx0Q==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.11", + "@esbuild/android-arm": "0.25.11", + "@esbuild/android-arm64": "0.25.11", + "@esbuild/android-x64": "0.25.11", + "@esbuild/darwin-arm64": "0.25.11", + "@esbuild/darwin-x64": "0.25.11", + "@esbuild/freebsd-arm64": "0.25.11", + "@esbuild/freebsd-x64": "0.25.11", + "@esbuild/linux-arm": "0.25.11", + "@esbuild/linux-arm64": "0.25.11", + "@esbuild/linux-ia32": "0.25.11", + "@esbuild/linux-loong64": "0.25.11", + "@esbuild/linux-mips64el": "0.25.11", + "@esbuild/linux-ppc64": "0.25.11", + "@esbuild/linux-riscv64": "0.25.11", + "@esbuild/linux-s390x": "0.25.11", + "@esbuild/linux-x64": "0.25.11", + "@esbuild/netbsd-arm64": "0.25.11", + "@esbuild/netbsd-x64": "0.25.11", + "@esbuild/openbsd-arm64": "0.25.11", + "@esbuild/openbsd-x64": "0.25.11", + "@esbuild/openharmony-arm64": "0.25.11", + "@esbuild/sunos-x64": "0.25.11", + "@esbuild/win32-arm64": "0.25.11", + "@esbuild/win32-ia32": "0.25.11", + "@esbuild/win32-x64": "0.25.11" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rollup": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.52.5.tgz", + "integrity": "sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.52.5", + "@rollup/rollup-android-arm64": "4.52.5", + "@rollup/rollup-darwin-arm64": "4.52.5", + "@rollup/rollup-darwin-x64": "4.52.5", + "@rollup/rollup-freebsd-arm64": "4.52.5", + "@rollup/rollup-freebsd-x64": "4.52.5", + "@rollup/rollup-linux-arm-gnueabihf": "4.52.5", + "@rollup/rollup-linux-arm-musleabihf": "4.52.5", + "@rollup/rollup-linux-arm64-gnu": "4.52.5", + "@rollup/rollup-linux-arm64-musl": "4.52.5", + "@rollup/rollup-linux-loong64-gnu": "4.52.5", + "@rollup/rollup-linux-ppc64-gnu": "4.52.5", + "@rollup/rollup-linux-riscv64-gnu": "4.52.5", + "@rollup/rollup-linux-riscv64-musl": "4.52.5", + "@rollup/rollup-linux-s390x-gnu": "4.52.5", + "@rollup/rollup-linux-x64-gnu": "4.52.5", + "@rollup/rollup-linux-x64-musl": "4.52.5", + "@rollup/rollup-openharmony-arm64": "4.52.5", + "@rollup/rollup-win32-arm64-msvc": "4.52.5", + "@rollup/rollup-win32-ia32-msvc": "4.52.5", + "@rollup/rollup-win32-x64-gnu": "4.52.5", + "@rollup/rollup-win32-x64-msvc": "4.52.5", + "fsevents": "~2.3.2" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", @@ -64,6 +1034,81 @@ "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "dev": true, "license": "MIT" + }, + "node_modules/vite": { + "version": "7.1.11", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.11.tgz", + "integrity": "sha512-uzcxnSDVjAopEUjljkWh8EIrg6tlzrjFUfMcR1EVsRDGwf/ccef0qQPRyOrROwhrTDaApueq+ja+KLPlzR/zdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } } } } diff --git a/reader/ts/package.json b/reader/ts/package.json index b8d443a..1a7f215 100644 --- a/reader/ts/package.json +++ b/reader/ts/package.json @@ -12,13 +12,14 @@ }, "type": "module", "scripts": { - "build": "tsc" + "build": "npx vite build && node dist/definition-reader.js" }, "author": "", "license": "", "devDependencies": { "@types/node": "^24.1.0", - "typescript": "^5.8.3" + "typescript": "^5.8.3", + "vite": "^7.1.11" }, "repository": { "type": "git", diff --git a/reader/ts/tsconfig.json b/reader/ts/tsconfig.json index 3f2c3b0..78520bf 100644 --- a/reader/ts/tsconfig.json +++ b/reader/ts/tsconfig.json @@ -1,5 +1,6 @@ { "exclude": ["node_modules", "build"], + "include": ["index.ts", "src/**/*.ts", "node_modules/@code0-tech/tucana/pb/**/*.ts"], "compilerOptions": { "lib": ["ESNext"], "module": "NodeNext", @@ -13,6 +14,6 @@ "emitDeclarationOnly": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "allowImportingTsExtensions": true, + "allowImportingTsExtensions": true } } diff --git a/reader/ts/vite.config.ts b/reader/ts/vite.config.ts new file mode 100644 index 0000000..1d8213f --- /dev/null +++ b/reader/ts/vite.config.ts @@ -0,0 +1,14 @@ +import { defineConfig } from 'vite'; + +export default defineConfig({ + build: { + lib: { + entry: './index.ts', // your entry file + formats: ['es'], // Node ESM + }, + outDir: 'dist', // output folder + rollupOptions: { + external: [/^node:.*$/], // Node built-ins + }, + }, +}); \ No newline at end of file From cca26e512045cbd268e4d185416edb21aa22bc8b Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:47:13 +0200 Subject: [PATCH 11/20] dependencies: updated tucana --- Cargo.lock | 19 +++---------------- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 062caf9..60491f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -293,7 +293,7 @@ dependencies = [ "serde_json", "tabled", "tokio", - "tucana 0.0.38", + "tucana", "zip", ] @@ -303,7 +303,7 @@ version = "0.0.0" dependencies = [ "serde", "serde_json", - "tucana 0.0.38", + "tucana", ] [[package]] @@ -314,7 +314,7 @@ checksum = "85d08bd4aad0f928b9f9731f174055e65b12f05ae49aa4c8e7f8e7d8e1b92211" dependencies = [ "serde", "serde_json", - "tucana 0.0.37", + "tucana", ] [[package]] @@ -2172,19 +2172,6 @@ dependencies = [ "tonic-prost-build", ] -[[package]] -name = "tucana" -version = "0.0.38" -dependencies = [ - "prost", - "prost-types", - "serde", - "serde_json", - "tonic", - "tonic-prost", - "tonic-prost-build", -] - [[package]] name = "typenum" version = "1.18.0" diff --git a/Cargo.toml b/Cargo.toml index a45641d..b39880a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ edition = "2024" [workspace.dependencies] serde = "1.0.219" serde_json = "1.0.140" -tucana = "0.0.36" +tucana = "0.0.37" clap = "4.5.41" colored = "3.0" tabled = "0.20" From ede55e42d5dc039f8f152e3ed0f64f7fb4885d59 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:47:38 +0200 Subject: [PATCH 12/20] fix: HTTP FlowType -> set host identifier to text --- definitions/http/flow_type/http.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/definitions/http/flow_type/http.json b/definitions/http/flow_type/http.json index 5c59274..0ececf3 100644 --- a/definitions/http/flow_type/http.json +++ b/definitions/http/flow_type/http.json @@ -40,7 +40,7 @@ { "identifier": "HTTP_HOST", "unique": false, - "data_type_identifier": "HTTP_HOST", + "data_type_identifier": "TEXT", "default_value": null, "name": [ { From 8512da7d44cd65332b467dffbf6bab572a0af278 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:47:50 +0200 Subject: [PATCH 13/20] feat: implemented binary bundling --- cli/src/command/bundle.rs | 48 +++++++++++++++++++++++++++++++++++ cli/src/command/definition.rs | 2 ++ cli/src/command/mod.rs | 1 + cli/src/main.rs | 7 +++++ 4 files changed, 58 insertions(+) create mode 100644 cli/src/command/bundle.rs diff --git a/cli/src/command/bundle.rs b/cli/src/command/bundle.rs new file mode 100644 index 0000000..c650994 --- /dev/null +++ b/cli/src/command/bundle.rs @@ -0,0 +1,48 @@ +use std::fs; +use std::io::Write; +use prost::Message; +use code0_definition_reader::parser::Parser; + +pub fn bundle(path: Option, out: Option) { + let dir_path = path.unwrap_or_else(|| "./definitions".to_string()); + let out_path = out.unwrap_or_else(|| "./bundles".to_string()); + match fs::create_dir_all(&out_path) { + Ok(_) => {} + Err(err) => { + panic!("Error creating output directory: {:?}", err); + } + } + + let parser = match Parser::from_path(dir_path.as_str()) { + Some(reader) => reader, + None => { + panic!("Error reading definitions"); + } + }; + + for feature in parser.features { + feature.data_types.iter().for_each(|data_type| { + let mut buf = Vec::new(); + if let Ok(_) = data_type.encode(&mut buf) { + let path = format!("{}/{}_{}_{}.pb",&out_path, feature.name, "data_type", data_type.identifier.to_lowercase()); + fs::File::create(&path).expect("abc").write_all(&buf).expect("a"); + } + }); + + feature.flow_types.iter().for_each(|flow_type| { + let mut buf = Vec::new(); + if let Ok(_) = flow_type.encode(&mut buf) { + let path = format!("{}/{}_{}_{}.pb",&out_path, feature.name, "flow_type", flow_type.identifier.to_lowercase()); + fs::File::create(&path).expect("abc").write_all(&buf).expect("a"); + } + }); + + feature.runtime_functions.iter().for_each(|function| { + let mut buf = Vec::new(); + if let Ok(_) = function.encode(&mut buf) { + let path = format!("{}/{}_{}_{}.pb",&out_path, feature.name, "function", function.runtime_name.to_lowercase()); + fs::File::create(&path).expect("abc").write_all(&buf).expect("a"); + } + }); + } +} \ No newline at end of file diff --git a/cli/src/command/definition.rs b/cli/src/command/definition.rs index b04a8cc..cf52423 100644 --- a/cli/src/command/definition.rs +++ b/cli/src/command/definition.rs @@ -1,6 +1,8 @@ use crate::formatter::{info, success}; use code0_definition_reader::parser::Parser; use colored::Colorize; +use prost::Message; +use tucana::shared::DefinitionDataType; pub fn search_definition(name: String, path: Option) { let dir_path = path.unwrap_or_else(|| "./definitions".to_string()); diff --git a/cli/src/command/mod.rs b/cli/src/command/mod.rs index 351e876..0caa4df 100644 --- a/cli/src/command/mod.rs +++ b/cli/src/command/mod.rs @@ -3,3 +3,4 @@ pub mod download; pub mod feature; pub mod report; pub mod watch; +pub mod bundle; diff --git a/cli/src/main.rs b/cli/src/main.rs index 787d4ae..6f410a5 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -53,6 +53,12 @@ enum Commands { #[clap(short, long, value_parser, num_args = 1.., value_delimiter = ' ')] features: Option>, }, + Bundle { + #[arg(short, long)] + path: Option, + #[arg(short, long)] + out: Option, + } } #[tokio::main] @@ -60,6 +66,7 @@ async fn main() { let cli = Cli::parse(); match cli.command { + Commands::Bundle {path, out} => command::bundle::bundle(path, out), Commands::Report { path } => command::report::report_errors(path), Commands::Feature { name, path } => command::feature::search_feature(name, path), Commands::Definition { name, path } => command::definition::search_definition(name, path), From 4f83e275f49ba7a667b4b117d9f7eb009d1dc431 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:48:05 +0200 Subject: [PATCH 14/20] feat: adjusted publishing to bundling --- .github/workflows/release.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9926fb..ed098c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,9 +53,27 @@ jobs: - name: Checkout Code uses: actions/checkout@v5 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Build project + run: cargo run bundle --path ../definitions --out ../bundles + working-directory: "./cli" + - name: Archive definitions folder run: | - zip -r definitions.zip definitions + zip -r bundles.zip bundles - name: Create GitHub Release uses: softprops/action-gh-release@v2 @@ -63,7 +81,7 @@ jobs: tag_name: ${{ github.ref_name }} name: Release ${{ github.ref_name }} files: | - definitions.zip + bundles.zip generate_release_notes: true make_latest: true env: From 34a7c46629bfd10d5e081fa3f055665a2c949e56 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 22:52:41 +0200 Subject: [PATCH 15/20] drop: removed sorting because of the way data types are constructed --- reader/ts/index.ts | 3 - reader/ts/src/mapper/dataTypeSorter.ts | 114 ------------------------- 2 files changed, 117 deletions(-) delete mode 100644 reader/ts/src/mapper/dataTypeSorter.ts diff --git a/reader/ts/index.ts b/reader/ts/index.ts index c6d444a..1070ffa 100644 --- a/reader/ts/index.ts +++ b/reader/ts/index.ts @@ -1,5 +1,2 @@ -import {Definition} from "./src/parser.ts"; - export { Definition } from './src/parser.ts'; export type { Feature } from './src/types.ts'; -Definition("../../cli/bundles") \ No newline at end of file diff --git a/reader/ts/src/mapper/dataTypeSorter.ts b/reader/ts/src/mapper/dataTypeSorter.ts deleted file mode 100644 index e53a8c5..0000000 --- a/reader/ts/src/mapper/dataTypeSorter.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { - DefinitionDataType, - DefinitionDataTypeRule -} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; -import {DataTypeIdentifier} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; - -function topologicalSort(items: { type: string; dependsOn: string[] }[]) { - const map = new Map(); - const visited = new Set(); - const visiting = new Set(); - const result: { type: string; dependsOn: string[] }[] = []; - - // Build a lookup map - for (const item of items) { - map.set(item.type, item); - } - - // Recursive DFS - function visit(type: string) { - if (visited.has(type)) return; - if (visiting.has(type)) { - throw new Error(`Cyclic dependency detected involving "${type}"`); - } - - visiting.add(type); - const item = map.get(type); - if (item) { - for (const dep of item.dependsOn) { - visit(dep); - } - result.push(item); - } - visiting.delete(type); - visited.add(type); - } - - // Visit all nodes - for (const item of items) { - visit(item.type); - } - - return result; -} - -function resolveDataTypeIdentifier(dataTypeIdentifier: DataTypeIdentifier | undefined): string[] { - const result: string[] = []; - - if (dataTypeIdentifier == undefined) { - return result - } - const dataType: any = dataTypeIdentifier! - - if (dataType.type.GenericType) { - result.push(dataType.type.GenericType.data_type_identifier) - // @ts-ignore - dataType.type.GenericType.generic_mappers.forEach(mapper => { - // @ts-ignore - mapper.source.forEach(source => { - result.push(...resolveDataTypeIdentifier(source)) - }) - }) - return result - } - - if (dataType.type.DataTypeIdentifier) { - return [dataType.type.DataTypeIdentifier] - } - - return result; -} - -function getDependencies(rule: DefinitionDataTypeRule): string[] { - const config: any = rule.config; - if (config.ContainsType) { - const dataTypeIdentifier = config.ContainsType.data_type_identifier - return resolveDataTypeIdentifier(dataTypeIdentifier) - } - - if (config.InputTypes) { - // @ts-ignore - const dataTypes = config.InputTypes.input_types.map(input => input.data_type_identifier) - return dataTypes.map(resolveDataTypeIdentifier).flat() - } - - if (config.ParentType) { - return resolveDataTypeIdentifier(config.ParentType.parent_type) - } - - if (config.ReturnType) { - return resolveDataTypeIdentifier(config.ReturnType.data_type_identifier) - } - - return [] -} - -function sortDataTypes(types: DefinitionDataType[]) { - const identifiable = types.map(type => { - const dependencies = type.rules?.map(rule => getDependencies(rule)).flat() ?? [] - return { - type: type.identifier, - dependsOn: dependencies - } - }) - - const sorted = topologicalSort(identifiable) - - for (const item of sorted) { - console.log(item) - } - - return sorted.map(item => types.find(type => type.identifier === item.type)) -} - -export {sortDataTypes} \ No newline at end of file From 4836d3169fd02c9fb959a8101f61870408081488 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 23:16:30 +0200 Subject: [PATCH 16/20] feat: added correct feature export --- .../mapper/{helper.ts => dataTypeMapper.ts} | 14 +- reader/ts/src/mapper/flowTypeMapper.ts | 3 +- reader/ts/src/mapper/functionMapper.ts | 3 +- reader/ts/src/mapper/translation.ts | 9 ++ reader/ts/src/parser.ts | 127 +++++++++++------- 5 files changed, 96 insertions(+), 60 deletions(-) rename reader/ts/src/mapper/{helper.ts => dataTypeMapper.ts} (96%) create mode 100644 reader/ts/src/mapper/translation.ts diff --git a/reader/ts/src/mapper/helper.ts b/reader/ts/src/mapper/dataTypeMapper.ts similarity index 96% rename from reader/ts/src/mapper/helper.ts rename to reader/ts/src/mapper/dataTypeMapper.ts index 3c66429..e776d31 100644 --- a/reader/ts/src/mapper/helper.ts +++ b/reader/ts/src/mapper/dataTypeMapper.ts @@ -15,6 +15,7 @@ import { } from "@code0-tech/tucana/pb/shared.data_type_pb.ts" import {GenericMapper as TucanaGenericMapper} from "@code0-tech/tucana/pb/shared.data_type_pb.ts" import {ConstructedDataTypes} from "../parser.js"; +import {getTranslationConnection} from "./translation.js"; export enum GenericMapper_GenericCombinationStrategy { UNKNOWN = 0, @@ -53,9 +54,7 @@ function getDataType(identifier: string, constructedDataTypes: ConstructedDataTy if (dataType == undefined) { const tucanaDataType = constructedDataTypes.scannedTucanaTypes.find(dt => dt.identifier === identifier) if (tucanaDataType == undefined) { - console.dir(constructedDataTypes, {depth: null}) - console.log("just skipping identifier") - console.log(identifier) + console.error("Skipping Identifier because it can't be identified:" + identifier) return null } const constructed = { @@ -252,11 +251,4 @@ function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined, return null; } -function getTranslationConnection(translation: Translation[]): TranslationConnection { - return { - count: translation.length, - nodes: translation, - } -} - -export {getDataType, getDataTypeIdentifier, getTranslationConnection} \ No newline at end of file +export {getDataType, getDataTypeIdentifier} \ No newline at end of file diff --git a/reader/ts/src/mapper/flowTypeMapper.ts b/reader/ts/src/mapper/flowTypeMapper.ts index c599190..657359e 100644 --- a/reader/ts/src/mapper/flowTypeMapper.ts +++ b/reader/ts/src/mapper/flowTypeMapper.ts @@ -1,7 +1,8 @@ import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.ts" import {FlowType, FlowTypeSetting} from "@code0-tech/sagittarius-graphql-types"; -import {getDataType, getTranslationConnection} from "./helper.ts"; +import {getDataType} from "./dataTypeMapper.ts"; import {ConstructedDataTypes} from "../parser.ts"; +import {getTranslationConnection} from "./translation.js"; function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes): FlowType | null { return { diff --git a/reader/ts/src/mapper/functionMapper.ts b/reader/ts/src/mapper/functionMapper.ts index 48dd0bc..a13b269 100644 --- a/reader/ts/src/mapper/functionMapper.ts +++ b/reader/ts/src/mapper/functionMapper.ts @@ -3,8 +3,9 @@ import { RuntimeFunctionDefinition as TucanaFunction, RuntimeParameterDefinition } from "@code0-tech/tucana/pb/shared.runtime_function_pb.ts"; -import {getDataTypeIdentifier, getTranslationConnection} from "./helper.ts"; +import {getDataTypeIdentifier} from "./dataTypeMapper.ts"; import {ConstructedDataTypes} from "../parser.ts"; +import {getTranslationConnection} from "./translation.js"; function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): FunctionDefinition | null { return { diff --git a/reader/ts/src/mapper/translation.ts b/reader/ts/src/mapper/translation.ts new file mode 100644 index 0000000..fecd963 --- /dev/null +++ b/reader/ts/src/mapper/translation.ts @@ -0,0 +1,9 @@ +import {Translation} from "@code0-tech/tucana/pb/shared.translation_pb.js"; +import {TranslationConnection} from "@code0-tech/sagittarius-graphql-types"; + +export function getTranslationConnection(translation: Translation[]): TranslationConnection { + return { + count: translation.length, + nodes: translation, + } +} diff --git a/reader/ts/src/parser.ts b/reader/ts/src/parser.ts index 4547762..d0415ee 100644 --- a/reader/ts/src/parser.ts +++ b/reader/ts/src/parser.ts @@ -6,85 +6,118 @@ import {RuntimeFunctionDefinition as TucanaFunction} from "@code0-tech/tucana/pb import path from "node:path"; import {mapFlowType} from "./mapper/flowTypeMapper.ts"; import {mapFunction} from "./mapper/functionMapper.ts"; -import {DataType, FlowType, FunctionDefinition} from "@code0-tech/sagittarius-graphql-types"; +import {DataType} from "@code0-tech/sagittarius-graphql-types"; import {DefinitionDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"; -import {getDataType} from "./mapper/helper.ts"; +import {getDataType} from "./mapper/dataTypeMapper.ts"; export interface ConstructedDataTypes { scannedTucanaTypes: DefinitionDataType[] constructedDataTypes: DataType[] } -export const Definition = (rootPath: string) => { - const dataTypes: TucanaDataType[] = [] - const runtimeFunctions: TucanaFunction[] = []; - const flowTypes: TucanaFlowType[] = []; - console.log(rootPath) - path.join() +export const Definition = (rootPath: string): Feature[] => { + const dataTypes: {feature: string, type: TucanaDataType}[] = [] + const runtimeFunctions: {feature: string, func: TucanaFunction}[] = []; + const flowTypes: {feature: string, flow: TucanaFlowType}[] = []; + readdirSync(rootPath, { withFileTypes: true }).forEach(file => { - console.log(file) + const featureName = file.name.split("_")[0] + if (featureName == null) { + throw new Error("Feature name is null") + } + const filePath = path.join(file.parentPath, file.name) - console.log(filePath) const content = readFileSync(filePath); if (file.name.includes("data_type")) { const decoded = TucanaDataType.fromBinary(content); - dataTypes.push(decoded) + dataTypes.push( + { + feature: featureName, + type: decoded, + } + ) } if (file.name.includes("function")) { const decoded = TucanaFunction.fromBinary(content); - runtimeFunctions.push(decoded) + runtimeFunctions.push( + { + feature: featureName, + func: decoded, + } + ) } if (file.name.includes("flow_type")) { const decoded = TucanaFlowType.fromBinary(content); - flowTypes.push(decoded) + flowTypes.push( + { + feature: featureName, + flow: decoded, + } + ) } }) + + const features: Feature[] = [] const constructed: ConstructedDataTypes = { - scannedTucanaTypes: dataTypes, + scannedTucanaTypes: dataTypes.map(f => f.type), constructedDataTypes: [] } - dataTypes.map(f => getDataType(f.identifier, constructed)).forEach((d: DataType | null) => console.dir(d, {depth: null})) - runtimeFunctions.map(f => mapFunction(f, constructed)).forEach((f: FunctionDefinition | null) => console.dir(f, {depth: null})) - flowTypes.map(f => mapFlowType(f, constructed)).forEach((f: FlowType | null) => console.dir(f, {depth: null})) - //throw new Error("Not implemented") - /* - const dt = meta.filter(m => m.type == MetaType.DataType).map(m => { - // console.log(m.data) - // return DefinitionDataType.fromJsonString(m.data) - // console.dir(def, {depth: null}) - return null; - }); - for (const d of dt) { - // console.dir(d, {depth: null}) - } - const sortedDt = sortDataTypes(dt).map(d => mapDataType(d)) + function getFeature(name:string): Feature { + const feature = features.find((f) => f.name === name); + if (feature != undefined) { + return feature; + } + + const newFeature = { + name: name, + dataTypes: [], + flowTypes: [], + runtimeFunctions: [], + }; - for (const dt of sortedDt) { - console.log(dt) + features.push(newFeature); + return newFeature; } - for (const m of meta) { - let feature = features.find((f) => f.name === m.name); + dataTypes.map(f => { + return { + name: f.feature, + type: getDataType(f.type.identifier, constructed) + } + }).forEach(dt => { + if (dt.type != null) { + const feature = getFeature(dt.name) + feature.dataTypes.push(dt.type) + } + }) + + runtimeFunctions.map(f => { + return { + name: f.feature, + type: mapFunction(f.func, constructed) + } + }).forEach(dt => { + if (dt.type != null) { + const feature = getFeature(dt.name) + feature.runtimeFunctions.push(dt.type) + } + }) - if (feature) { - appendMeta(feature, m); - } else { - feature = { - name: m.name, - dataTypes: [], - flowTypes: [], - runtimeFunctions: [], - }; - appendMeta(feature, m); - features.push(feature); + flowTypes.map(f => { + return { + name: f.feature, + type: mapFlowType(f.flow, constructed) } - } + }).forEach(dt => { + if (dt.type != null) { + const feature = getFeature(dt.name) + feature.flowTypes.push(dt.type) + } + }) return features; - - */ } From cc2ceb05584a32635cc017c19162b543bf9fa94f Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Oct 2025 23:19:32 +0200 Subject: [PATCH 17/20] ref: cargo fmt --- cli/src/command/bundle.rs | 45 +++++++++++++++++++++++++++++++-------- cli/src/command/mod.rs | 2 +- cli/src/main.rs | 4 ++-- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/cli/src/command/bundle.rs b/cli/src/command/bundle.rs index c650994..6ac29f9 100644 --- a/cli/src/command/bundle.rs +++ b/cli/src/command/bundle.rs @@ -1,7 +1,7 @@ +use code0_definition_reader::parser::Parser; +use prost::Message; use std::fs; use std::io::Write; -use prost::Message; -use code0_definition_reader::parser::Parser; pub fn bundle(path: Option, out: Option) { let dir_path = path.unwrap_or_else(|| "./definitions".to_string()); @@ -24,25 +24,52 @@ pub fn bundle(path: Option, out: Option) { feature.data_types.iter().for_each(|data_type| { let mut buf = Vec::new(); if let Ok(_) = data_type.encode(&mut buf) { - let path = format!("{}/{}_{}_{}.pb",&out_path, feature.name, "data_type", data_type.identifier.to_lowercase()); - fs::File::create(&path).expect("abc").write_all(&buf).expect("a"); + let path = format!( + "{}/{}_{}_{}.pb", + &out_path, + feature.name, + "data_type", + data_type.identifier.to_lowercase() + ); + fs::File::create(&path) + .expect("abc") + .write_all(&buf) + .expect("a"); } }); feature.flow_types.iter().for_each(|flow_type| { let mut buf = Vec::new(); if let Ok(_) = flow_type.encode(&mut buf) { - let path = format!("{}/{}_{}_{}.pb",&out_path, feature.name, "flow_type", flow_type.identifier.to_lowercase()); - fs::File::create(&path).expect("abc").write_all(&buf).expect("a"); + let path = format!( + "{}/{}_{}_{}.pb", + &out_path, + feature.name, + "flow_type", + flow_type.identifier.to_lowercase() + ); + fs::File::create(&path) + .expect("abc") + .write_all(&buf) + .expect("a"); } }); feature.runtime_functions.iter().for_each(|function| { let mut buf = Vec::new(); if let Ok(_) = function.encode(&mut buf) { - let path = format!("{}/{}_{}_{}.pb",&out_path, feature.name, "function", function.runtime_name.to_lowercase()); - fs::File::create(&path).expect("abc").write_all(&buf).expect("a"); + let path = format!( + "{}/{}_{}_{}.pb", + &out_path, + feature.name, + "function", + function.runtime_name.to_lowercase() + ); + fs::File::create(&path) + .expect("abc") + .write_all(&buf) + .expect("a"); } }); } -} \ No newline at end of file +} diff --git a/cli/src/command/mod.rs b/cli/src/command/mod.rs index 0caa4df..98036f8 100644 --- a/cli/src/command/mod.rs +++ b/cli/src/command/mod.rs @@ -1,6 +1,6 @@ +pub mod bundle; pub mod definition; pub mod download; pub mod feature; pub mod report; pub mod watch; -pub mod bundle; diff --git a/cli/src/main.rs b/cli/src/main.rs index 6f410a5..a4e185e 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -58,7 +58,7 @@ enum Commands { path: Option, #[arg(short, long)] out: Option, - } + }, } #[tokio::main] @@ -66,7 +66,7 @@ async fn main() { let cli = Cli::parse(); match cli.command { - Commands::Bundle {path, out} => command::bundle::bundle(path, out), + Commands::Bundle { path, out } => command::bundle::bundle(path, out), Commands::Report { path } => command::report::report_errors(path), Commands::Feature { name, path } => command::feature::search_feature(name, path), Commands::Definition { name, path } => command::definition::search_definition(name, path), From ed2e1940120fc441f9a2c1c2b3eb0b82cd2feef4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 23 Oct 2025 18:55:47 +0200 Subject: [PATCH 18/20] feat: added id field to every constructed type --- reader/ts/src/mapper/dataTypeMapper.ts | 16 ++++++++++------ reader/ts/src/mapper/flowTypeMapper.ts | 8 ++++++-- reader/ts/src/mapper/functionMapper.ts | 4 +++- reader/ts/src/parser.ts | 10 +++++++++- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/reader/ts/src/mapper/dataTypeMapper.ts b/reader/ts/src/mapper/dataTypeMapper.ts index e776d31..63639ed 100644 --- a/reader/ts/src/mapper/dataTypeMapper.ts +++ b/reader/ts/src/mapper/dataTypeMapper.ts @@ -5,16 +5,14 @@ import { DataTypeRulesInputTypeConfig, DataTypeRulesInputTypesConfig, DataTypeRulesItemOfCollectionConfig, DataTypeRulesNumberRangeConfig, - DataTypeRulesParentTypeConfig, DataTypeRulesRegexConfig, GenericCombinationStrategy, - TranslationConnection + DataTypeRulesParentTypeConfig, DataTypeRulesRegexConfig, } from "@code0-tech/sagittarius-graphql-types"; -import {Translation} from "@code0-tech/tucana/pb/shared.translation_pb.ts"; import { DataTypeIdentifier as TucanaDataTypeIdentifier, DefinitionDataType_Variant, DefinitionDataTypeRule } from "@code0-tech/tucana/pb/shared.data_type_pb.ts" import {GenericMapper as TucanaGenericMapper} from "@code0-tech/tucana/pb/shared.data_type_pb.ts" -import {ConstructedDataTypes} from "../parser.js"; +import {ConstructedDataTypes, getID} from "../parser.js"; import {getTranslationConnection} from "./translation.js"; export enum GenericMapper_GenericCombinationStrategy { @@ -57,7 +55,8 @@ function getDataType(identifier: string, constructedDataTypes: ConstructedDataTy console.error("Skipping Identifier because it can't be identified:" + identifier) return null } - const constructed = { + const constructed: DataType = { + id: `gid://sagittarius/DataType/${getID(constructedDataTypes)}`, genericKeys: tucanaDataType.genericKeys, identifier: tucanaDataType.identifier, name: getTranslationConnection(tucanaDataType.name), @@ -204,7 +203,9 @@ function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined, switch (identifier.type.oneofKind) { case "genericType": { return { + id: `gid://sagittarius/DataTypeIdentifier/${getID(constructedDataTypes)}`, genericType: { + id: `gid://sagittarius/GenericType/${getID(constructedDataTypes)}`, dataType: getDataType(identifier.type.genericType.dataTypeIdentifier, constructedDataTypes), genericMappers: identifier.type.genericType.genericMappers.map((mapper: TucanaGenericMapper) => { return { @@ -220,8 +221,8 @@ function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined, default: throw new Error("GenericCombinationStrategy was Unknown"); } - return { + id: `gid://sagittarius/GenericCombinationStrategy/${getID(constructedDataTypes)}`, type: type } }), @@ -229,6 +230,7 @@ function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined, getDataTypeIdentifier(id, constructedDataTypes) ).filter(id => id != null), target: mapper.target, + id: `gid://sagittarius/GenericMapper/${getID(constructedDataTypes)}`, } }), } @@ -237,12 +239,14 @@ function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined, case "dataTypeIdentifier": { return { + id: `gid://sagittarius/DataTypeIdentifier/${getID(constructedDataTypes)}`, dataType: getDataType(identifier.type.dataTypeIdentifier, constructedDataTypes) } } case "genericKey": { return { + id: `gid://sagittarius/DataTypeIdentifier/${getID(constructedDataTypes)}`, genericKey: identifier.type.genericKey, } } diff --git a/reader/ts/src/mapper/flowTypeMapper.ts b/reader/ts/src/mapper/flowTypeMapper.ts index 657359e..e93d0f5 100644 --- a/reader/ts/src/mapper/flowTypeMapper.ts +++ b/reader/ts/src/mapper/flowTypeMapper.ts @@ -1,11 +1,12 @@ import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.ts" import {FlowType, FlowTypeSetting} from "@code0-tech/sagittarius-graphql-types"; import {getDataType} from "./dataTypeMapper.ts"; -import {ConstructedDataTypes} from "../parser.ts"; +import {ConstructedDataTypes, getID} from "../parser.ts"; import {getTranslationConnection} from "./translation.js"; function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes): FlowType | null { return { + id: `gid://sagittarius/TypesFlowType/${getID(constructed)}`, identifier: flowType.identifier, inputType: getDataType(flowType.inputTypeIdentifier!!, constructed), returnType: getDataType(flowType.returnTypeIdentifier!!, constructed), @@ -18,13 +19,16 @@ function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes function createFlowTypeSetting(settings: TucanaFlowTypeSetting[], constructed: ConstructedDataTypes): FlowTypeSetting[] { return settings.map(setting => { - return { + const flowSetting: 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 } + + return flowSetting; }) } diff --git a/reader/ts/src/mapper/functionMapper.ts b/reader/ts/src/mapper/functionMapper.ts index a13b269..f16cdc1 100644 --- a/reader/ts/src/mapper/functionMapper.ts +++ b/reader/ts/src/mapper/functionMapper.ts @@ -4,11 +4,12 @@ import { RuntimeParameterDefinition } from "@code0-tech/tucana/pb/shared.runtime_function_pb.ts"; import {getDataTypeIdentifier} from "./dataTypeMapper.ts"; -import {ConstructedDataTypes} from "../parser.ts"; +import {ConstructedDataTypes, getID} from "../parser.ts"; import {getTranslationConnection} from "./translation.js"; function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): FunctionDefinition | null { return { + id: `gid://sagittarius/FunctionDefinition/${getID(constructed)}`, genericKeys: func.genericKeys, names: getTranslationConnection(func.name), descriptions: getTranslationConnection(func.description), @@ -25,6 +26,7 @@ function getParameterDefinitionConnection(def: RuntimeParameterDefinition[], con count: def.length, nodes: def.map(node => { return { + id: `gid://sagittarius/ParameterDefinition/${getID(constructed)}`, names: getTranslationConnection(node.name), descriptions: getTranslationConnection(node.description), documentations: getTranslationConnection(node.documentation), diff --git a/reader/ts/src/parser.ts b/reader/ts/src/parser.ts index d0415ee..39e51e7 100644 --- a/reader/ts/src/parser.ts +++ b/reader/ts/src/parser.ts @@ -13,6 +13,13 @@ import {getDataType} from "./mapper/dataTypeMapper.ts"; export interface ConstructedDataTypes { scannedTucanaTypes: DefinitionDataType[] constructedDataTypes: DataType[] + id: number +} + +export function getID(constructedDataTypes: ConstructedDataTypes) { + const last = constructedDataTypes.id + constructedDataTypes.id += 1 + return last } export const Definition = (rootPath: string): Feature[] => { @@ -63,7 +70,8 @@ export const Definition = (rootPath: string): Feature[] => { const features: Feature[] = [] const constructed: ConstructedDataTypes = { scannedTucanaTypes: dataTypes.map(f => f.type), - constructedDataTypes: [] + constructedDataTypes: [], + id: 0 } function getFeature(name:string): Feature { From 95dfa42fbf1cdf44c47abfbaa817c0cd333a18dd Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 23 Oct 2025 19:04:14 +0200 Subject: [PATCH 19/20] dependencies: updated sag. types --- reader/ts/package-lock.json | 20 ++++++++++---------- reader/ts/package.json | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/reader/ts/package-lock.json b/reader/ts/package-lock.json index f997296..18e3e74 100644 --- a/reader/ts/package-lock.json +++ b/reader/ts/package-lock.json @@ -8,7 +8,7 @@ "name": "@code0-tech/definition-reader", "version": "0.0.0", "dependencies": { - "@code0-tech/sagittarius-graphql-types": "^0.0.0-967667e8c736081887d32d99a5e2ab0445718798", + "@code0-tech/sagittarius-graphql-types": "^0.0.0-3dbc1d7dffaa541501b2cb0954dabc06a9288cf6", "@code0-tech/tucana": "^0.0.37", "@protobuf-ts/runtime": "^2.11.1" }, @@ -19,9 +19,9 @@ } }, "node_modules/@code0-tech/sagittarius-graphql-types": { - "version": "0.0.0-967667e8c736081887d32d99a5e2ab0445718798", - "resolved": "https://registry.npmjs.org/@code0-tech/sagittarius-graphql-types/-/sagittarius-graphql-types-0.0.0-967667e8c736081887d32d99a5e2ab0445718798.tgz", - "integrity": "sha512-YZ3AcTfb3AOfUz7+4co0Jo5u1yaPDoW6KXweklxn1smaEvpNd/RbAoqrFEF9bXAtFG+wacqqBy72dCy7XyfpoA==" + "version": "0.0.0-3dbc1d7dffaa541501b2cb0954dabc06a9288cf6", + "resolved": "https://registry.npmjs.org/@code0-tech/sagittarius-graphql-types/-/sagittarius-graphql-types-0.0.0-3dbc1d7dffaa541501b2cb0954dabc06a9288cf6.tgz", + "integrity": "sha512-523cUgWKTNSqqZit659cFh/RA7pdQDinMBGhA+4tYdMKq0fq6jHcDloS7RKnCfKG2tz5iIBC75Va/S+Yn1+csg==" }, "node_modules/@code0-tech/tucana": { "version": "0.0.37", @@ -793,9 +793,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.0.tgz", - "integrity": "sha512-MKNwXh3seSK8WurXF7erHPJ2AONmMwkI7zAMrXZDPIru8jRqkk6rGDBVbw4mLwfqA+ZZliiDPg05JQ3uW66tKQ==", + "version": "24.9.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz", + "integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==", "dev": true, "license": "MIT", "dependencies": { @@ -1036,9 +1036,9 @@ "license": "MIT" }, "node_modules/vite": { - "version": "7.1.11", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.11.tgz", - "integrity": "sha512-uzcxnSDVjAopEUjljkWh8EIrg6tlzrjFUfMcR1EVsRDGwf/ccef0qQPRyOrROwhrTDaApueq+ja+KLPlzR/zdg==", + "version": "7.1.12", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.12.tgz", + "integrity": "sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug==", "dev": true, "license": "MIT", "dependencies": { diff --git a/reader/ts/package.json b/reader/ts/package.json index 1a7f215..5b80846 100644 --- a/reader/ts/package.json +++ b/reader/ts/package.json @@ -32,7 +32,7 @@ "access": "public" }, "dependencies": { - "@code0-tech/sagittarius-graphql-types": "^0.0.0-967667e8c736081887d32d99a5e2ab0445718798", + "@code0-tech/sagittarius-graphql-types": "^0.0.0-3dbc1d7dffaa541501b2cb0954dabc06a9288cf6", "@code0-tech/tucana": "^0.0.37", "@protobuf-ts/runtime": "^2.11.1" } From 94b337cfe330877c39fac6142f18ac816a6d63cc Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 23 Oct 2025 20:09:56 +0200 Subject: [PATCH 20/20] feat: updated to latest sag. types --- reader/ts/package-lock.json | 8 ++--- reader/ts/package.json | 2 +- reader/ts/src/mapper/dataTypeMapper.ts | 45 ++++---------------------- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/reader/ts/package-lock.json b/reader/ts/package-lock.json index 18e3e74..128b047 100644 --- a/reader/ts/package-lock.json +++ b/reader/ts/package-lock.json @@ -8,7 +8,7 @@ "name": "@code0-tech/definition-reader", "version": "0.0.0", "dependencies": { - "@code0-tech/sagittarius-graphql-types": "^0.0.0-3dbc1d7dffaa541501b2cb0954dabc06a9288cf6", + "@code0-tech/sagittarius-graphql-types": "^0.0.0-3bdab57d324cfeb2abf2cf60a801039b45de746d", "@code0-tech/tucana": "^0.0.37", "@protobuf-ts/runtime": "^2.11.1" }, @@ -19,9 +19,9 @@ } }, "node_modules/@code0-tech/sagittarius-graphql-types": { - "version": "0.0.0-3dbc1d7dffaa541501b2cb0954dabc06a9288cf6", - "resolved": "https://registry.npmjs.org/@code0-tech/sagittarius-graphql-types/-/sagittarius-graphql-types-0.0.0-3dbc1d7dffaa541501b2cb0954dabc06a9288cf6.tgz", - "integrity": "sha512-523cUgWKTNSqqZit659cFh/RA7pdQDinMBGhA+4tYdMKq0fq6jHcDloS7RKnCfKG2tz5iIBC75Va/S+Yn1+csg==" + "version": "0.0.0-3bdab57d324cfeb2abf2cf60a801039b45de746d", + "resolved": "https://registry.npmjs.org/@code0-tech/sagittarius-graphql-types/-/sagittarius-graphql-types-0.0.0-3bdab57d324cfeb2abf2cf60a801039b45de746d.tgz", + "integrity": "sha512-UzB9ugIJmOTH1t5t7u4+ZdbNbW8W1HlOCRagWKKiCSUkOS9FeQomiLmKT7LU0qxmzkHW0RoJg2dn4YrsA1i+zA==" }, "node_modules/@code0-tech/tucana": { "version": "0.0.37", diff --git a/reader/ts/package.json b/reader/ts/package.json index 5b80846..624d4bf 100644 --- a/reader/ts/package.json +++ b/reader/ts/package.json @@ -32,7 +32,7 @@ "access": "public" }, "dependencies": { - "@code0-tech/sagittarius-graphql-types": "^0.0.0-3dbc1d7dffaa541501b2cb0954dabc06a9288cf6", + "@code0-tech/sagittarius-graphql-types": "^0.0.0-3bdab57d324cfeb2abf2cf60a801039b45de746d", "@code0-tech/tucana": "^0.0.37", "@protobuf-ts/runtime": "^2.11.1" } diff --git a/reader/ts/src/mapper/dataTypeMapper.ts b/reader/ts/src/mapper/dataTypeMapper.ts index 63639ed..81e7b88 100644 --- a/reader/ts/src/mapper/dataTypeMapper.ts +++ b/reader/ts/src/mapper/dataTypeMapper.ts @@ -5,47 +5,16 @@ import { DataTypeRulesInputTypeConfig, DataTypeRulesInputTypesConfig, DataTypeRulesItemOfCollectionConfig, DataTypeRulesNumberRangeConfig, - DataTypeRulesParentTypeConfig, DataTypeRulesRegexConfig, + DataTypeRulesParentTypeConfig, DataTypeRulesRegexConfig, DataTypeRulesVariant, DataTypeVariant, + GenericCombinationStrategyType, } from "@code0-tech/sagittarius-graphql-types"; import { DataTypeIdentifier as TucanaDataTypeIdentifier, - DefinitionDataType_Variant, DefinitionDataTypeRule + DefinitionDataType_Variant, DefinitionDataTypeRule, GenericMapper_GenericCombinationStrategy } from "@code0-tech/tucana/pb/shared.data_type_pb.ts" import {GenericMapper as TucanaGenericMapper} from "@code0-tech/tucana/pb/shared.data_type_pb.ts" -import {ConstructedDataTypes, getID} from "../parser.js"; -import {getTranslationConnection} from "./translation.js"; - -export enum GenericMapper_GenericCombinationStrategy { - UNKNOWN = 0, - AND = 1, - OR = 2 -} - -export enum GenericCombinationStrategyType { - And = 'AND', - Or = 'OR' -} - -enum DataTypeVariant { - Array = 'ARRAY', - DataType = 'DATA_TYPE', - Error = 'ERROR', - Node = 'NODE', - Object = 'OBJECT', - Primitive = 'PRIMITIVE', - Type = 'TYPE' -} - -enum DataTypeRulesVariant { - ContainsKey = 'CONTAINS_KEY', - ContainsType = 'CONTAINS_TYPE', - InputType = 'INPUT_TYPE', - ItemOfCollection = 'ITEM_OF_COLLECTION', - NumberRange = 'NUMBER_RANGE', - ParentType = 'PARENT_TYPE', - Regex = 'REGEX', - ReturnType = 'RETURN_TYPE' -} +import {ConstructedDataTypes, getID} from "../parser.ts"; +import {getTranslationConnection} from "./translation.ts"; function getDataType(identifier: string, constructedDataTypes: ConstructedDataTypes): DataType | null { const dataType = constructedDataTypes.constructedDataTypes.find(dt => dt.identifier === identifier) @@ -77,7 +46,7 @@ function createRules(rule: DefinitionDataTypeRule[], constructedDataTypes: Const switch (r.config.oneofKind) { case "containsType": { const ruleConfig: DataTypeRulesContainsTypeConfig = { - dataTypeIdentifier: getDataTypeIdentifier(r.config.containsType.dataTypeIdentifier, constructedDataTypes), //TODO + dataTypeIdentifier: getDataTypeIdentifier(r.config.containsType.dataTypeIdentifier, constructedDataTypes), } const rule: DataTypeRule = { variant: DataTypeRulesVariant.ContainsType, @@ -134,7 +103,7 @@ function createRules(rule: DefinitionDataTypeRule[], constructedDataTypes: Const console.log("AF: " + i.inputIdentifier) const input: DataTypeRulesInputTypeConfig = { dataTypeIdentifier: getDataTypeIdentifier(i.dataTypeIdentifier, constructedDataTypes), - inputType: null, //TODO (Later): This field is wrong in GraphQL => should be a string + inputIdentifier: i.inputIdentifier, } return input; }),