Skip to content

Commit 2b15c08

Browse files
committed
Fixup tucana version
1 parent 6f38ade commit 2b15c08

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

package/reader/src/index.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import {readdir, readFile} from "node:fs/promises";
22
import {join, extname} from "node:path";
3-
4-
import {FlowType} from "@code0-tech/tucana/pb/shared.flow_definition_pb.js";
5-
import {RuntimeFunctionDefinition} from "@code0-tech/tucana/pb/shared.runtime_function_pb.js";
6-
import {DefinitionDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.js";
3+
import {DefinitionDataType, FlowType, FunctionDefinition, RuntimeFunctionDefinition} from "@code0-tech/tucana/shared";
74

85
export const enum MetaType {
96
FlowType = "FlowType",
107
DataType = "DataType",
118
RuntimeFunction = "RuntimeFunction",
9+
Function = "Function"
1210
}
1311

1412
export interface DefinitionError {
@@ -22,6 +20,7 @@ export interface Feature {
2220
data_types: DefinitionDataType[];
2321
flow_types: FlowType[];
2422
runtime_functions: RuntimeFunctionDefinition[];
23+
functions: FunctionDefinition[];
2524
errors: DefinitionError[];
2625
}
2726

@@ -58,14 +57,16 @@ const toMetaType = (folder: string): MetaType | null =>
5857
({
5958
flow_type: MetaType.FlowType,
6059
data_type: MetaType.DataType,
61-
runtime_definition: MetaType.RuntimeFunction
60+
runtime_definition: MetaType.RuntimeFunction,
61+
function: MetaType.Function,
6262
} as const)[folder] ?? null;
6363

6464
const emptyFeature = (name: string): Feature => ({
6565
name,
6666
data_types: [],
6767
flow_types: [],
6868
runtime_functions: [],
69+
functions: [],
6970
errors: [],
7071
});
7172

@@ -93,9 +94,22 @@ const collectJsonFiles = async (dir: string): Promise<string[]> => {
9394

9495
const addDefinition = (feature: Feature, def: string, type: MetaType) => {
9596
try {
96-
if (type === MetaType.DataType) feature.data_types.push(DefinitionDataType.fromJsonString(def));
97-
else if (type === MetaType.FlowType) feature.flow_types.push(FlowType.fromJsonString(def));
98-
else feature.runtime_functions.push(RuntimeFunctionDefinition.fromJsonString(def));
97+
switch (type) {
98+
case MetaType.DataType:
99+
feature.data_types.push(DefinitionDataType.fromJsonString(def));
100+
break
101+
case MetaType.FlowType:
102+
feature.flow_types.push(FlowType.fromJsonString(def));
103+
break
104+
case MetaType.RuntimeFunction:
105+
feature.runtime_functions.push(RuntimeFunctionDefinition.fromJsonString(def));
106+
break
107+
case MetaType.Function:
108+
feature.functions.push(FunctionDefinition.fromJsonString(def));
109+
break
110+
default:
111+
throw new Error(`Unknown MetaType: ${type}`);
112+
}
99113
} catch (err) {
100114
feature.errors.push({
101115
definition: extractIdentifier(def, type),

package/reader/tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"exclude": ["node_modules", "build", "dist"],
3-
"include": ["node_modules/@code0-tech/tucana/pb/**/*.ts"],
3+
"include": ["src/**/*"],
44
"types": [
55
"typePatches"
66
],
77
"compilerOptions": {
8-
"lib": ["ESNext"],
9-
"module": "NodeNext",
10-
"target": "ESNext",
8+
"lib": ["es2020"],
9+
"module": "commonjs",
10+
"target": "es2020",
1111
"skipLibCheck": true,
1212
"strict": true,
1313
"paths": {
@@ -17,7 +17,7 @@
1717
},
1818
"baseUrl": "src/",
1919
"sourceMap": true,
20-
"moduleResolution": "nodenext",
20+
"moduleResolution": "bundler",
2121
"declaration": true,
2222
"emitDeclarationOnly": true,
2323
"esModuleInterop": true,

0 commit comments

Comments
 (0)