Skip to content

Commit 62da7a8

Browse files
committed
feat: finished reader impl
1 parent 3c7b4be commit 62da7a8

File tree

10 files changed

+338
-307
lines changed

10 files changed

+338
-307
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
**/node_modules
44
.idea
55
reader/ts/src/*.js
6-
reader/ts/build
6+
reader/ts/build
7+
bundles
8+
reader/**/*.js

reader/ts/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Definition} from "./src/parser.ts";
22

33
export { Definition } from './src/parser.ts';
4-
export type { Feature, MetaType, Meta } from './src/types.ts';
5-
6-
const def = Definition("../../definitions/")
4+
export type { Feature } from './src/types.ts';
5+
Definition("../../cli/bundles")

reader/ts/src/mapper/dataTypeMapper.ts

Lines changed: 0 additions & 154 deletions
This file was deleted.

reader/ts/src/mapper/dataTypeSorter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ function resolveDataTypeIdentifier(dataTypeIdentifier: DataTypeIdentifier | unde
4848
if (dataTypeIdentifier == undefined) {
4949
return result
5050
}
51-
5251
const dataType: any = dataTypeIdentifier!
5352

5453
if (dataType.type.GenericType) {

reader/ts/src/mapper/flowTypeMapper.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.ts"
22
import {FlowType, FlowTypeSetting} from "@code0-tech/sagittarius-graphql-types";
33
import {getDataType, getTranslationConnection} from "./helper.ts";
4-
import {Meta, MetaType} from "../types.ts";
4+
import {ConstructedDataTypes} from "../parser.ts";
55

6-
function mapFlowType(meta: Meta): FlowType | null {
7-
if (meta.type != MetaType.FlowType) {
8-
console.error(`Expected FlowType, got ${meta.type}`);
9-
return null;
10-
}
11-
12-
const parsed = JSON.parse(meta.data) as TucanaFlowType;
6+
function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes): FlowType | null {
137
return {
14-
identifier: parsed.identifier,
15-
inputType: getDataType(parsed.inputTypeIdentifier),
16-
returnType: getDataType(parsed.returnTypeIdentifier),
17-
flowTypeSettings: createFlowTypeSetting(parsed.settings),
18-
names: getTranslationConnection(parsed.name),
19-
descriptions: getTranslationConnection(parsed.description),
20-
editable: parsed.editable
8+
identifier: flowType.identifier,
9+
inputType: getDataType(flowType.inputTypeIdentifier!!, constructed),
10+
returnType: getDataType(flowType.returnTypeIdentifier!!, constructed),
11+
flowTypeSettings: createFlowTypeSetting(flowType.settings, constructed),
12+
names: getTranslationConnection(flowType.name),
13+
descriptions: getTranslationConnection(flowType.description),
14+
editable: flowType.editable
2115
}
2216
}
2317

24-
function createFlowTypeSetting(settings: TucanaFlowTypeSetting[]): FlowTypeSetting[] {
18+
function createFlowTypeSetting(settings: TucanaFlowTypeSetting[], constructed: ConstructedDataTypes): FlowTypeSetting[] {
2519
return settings.map(setting => {
2620
return {
2721
names: getTranslationConnection(setting.name),
2822
descriptions: getTranslationConnection(setting.description),
29-
dataType: getDataType(setting.dataTypeIdentifier),
23+
dataType: getDataType(setting.dataTypeIdentifier, constructed),
3024
identifier: setting.identifier,
3125
unique: setting.unique
3226
}

reader/ts/src/mapper/functionMapper.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,33 @@
1-
import {Meta, MetaType} from "../types.ts";
21
import {FunctionDefinition, ParameterDefinitionConnection} from "@code0-tech/sagittarius-graphql-types";
32
import {
43
RuntimeFunctionDefinition as TucanaFunction,
54
RuntimeParameterDefinition
65
} from "@code0-tech/tucana/pb/shared.runtime_function_pb.ts";
76
import {getDataTypeIdentifier, getTranslationConnection} from "./helper.ts";
7+
import {ConstructedDataTypes} from "../parser.ts";
88

9-
function mapFunction(meta:Meta): FunctionDefinition | null {
10-
if (meta.type != MetaType.RuntimeFunction) {
11-
console.error(`Expected RuntimeFunction, got ${meta.type}`);
12-
return null;
13-
}
14-
15-
const parsed = JSON.parse(meta.data) as TucanaFunction;
9+
function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): FunctionDefinition | null {
1610
return {
17-
genericKeys: parsed.genericKeys,
18-
names: getTranslationConnection(parsed.name),
19-
descriptions: getTranslationConnection(parsed.description),
20-
documentations: getTranslationConnection(parsed.documentation),
21-
deprecationMessages: getTranslationConnection(parsed.deprecationMessage),
22-
throwsError: parsed.throwsError,
23-
returnType: getDataTypeIdentifier(parsed.returnTypeIdentifier),
24-
parameterDefinitions: getParameterDefinitionConnection(parsed.runtimeParameterDefinitions),
11+
genericKeys: func.genericKeys,
12+
names: getTranslationConnection(func.name),
13+
descriptions: getTranslationConnection(func.description),
14+
documentations: getTranslationConnection(func.documentation),
15+
deprecationMessages: getTranslationConnection(func.deprecationMessage),
16+
throwsError: func.throwsError,
17+
returnType: getDataTypeIdentifier(func.returnTypeIdentifier, constructed),
18+
parameterDefinitions: getParameterDefinitionConnection(func.runtimeParameterDefinitions, constructed),
2519
}
2620
}
2721

28-
function getParameterDefinitionConnection(def: RuntimeParameterDefinition[]): ParameterDefinitionConnection {
22+
function getParameterDefinitionConnection(def: RuntimeParameterDefinition[], constructed: ConstructedDataTypes): ParameterDefinitionConnection {
2923
return {
3024
count: def.length,
3125
nodes: def.map(node => {
3226
return {
3327
names: getTranslationConnection(node.name),
3428
descriptions: getTranslationConnection(node.description),
3529
documentations: getTranslationConnection(node.documentation),
36-
dataType: getDataTypeIdentifier(node.dataTypeIdentifier)
30+
dataType: getDataTypeIdentifier(node.dataTypeIdentifier, constructed)
3731
}
3832
})
3933
}

0 commit comments

Comments
 (0)