Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package/reader/package-lock.json

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

2 changes: 1 addition & 1 deletion package/reader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"access": "public"
},
"dependencies": {
"@code0-tech/tucana": "0.0.59",
"@code0-tech/tucana": "0.0.68",
"@protobuf-ts/runtime": "^2.11.1",
"@protobuf-ts/runtime-rpc": "^2.11.1",
"vite-plugin-dts": "^4.5.4"
Expand Down
30 changes: 22 additions & 8 deletions package/reader/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {readdir, readFile} from "node:fs/promises";
import {join, extname} from "node:path";

import {FlowType} from "@code0-tech/tucana/pb/shared.flow_definition_pb.js";
import {RuntimeFunctionDefinition} from "@code0-tech/tucana/pb/shared.runtime_function_pb.js";
import {DefinitionDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.js";
import {DefinitionDataType, FlowType, FunctionDefinition, RuntimeFunctionDefinition} from "@code0-tech/tucana/shared";

export const enum MetaType {
FlowType = "FlowType",
DataType = "DataType",
RuntimeFunction = "RuntimeFunction",
Function = "Function"
}

export interface DefinitionError {
Expand All @@ -22,6 +20,7 @@ export interface Feature {
data_types: DefinitionDataType[];
flow_types: FlowType[];
runtime_functions: RuntimeFunctionDefinition[];
functions: FunctionDefinition[];
errors: DefinitionError[];
}

Expand Down Expand Up @@ -58,14 +57,16 @@ const toMetaType = (folder: string): MetaType | null =>
({
flow_type: MetaType.FlowType,
data_type: MetaType.DataType,
runtime_definition: MetaType.RuntimeFunction
runtime_definition: MetaType.RuntimeFunction,
function: MetaType.Function,
} as const)[folder] ?? null;

const emptyFeature = (name: string): Feature => ({
name,
data_types: [],
flow_types: [],
runtime_functions: [],
functions: [],
errors: [],
});

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

const addDefinition = (feature: Feature, def: string, type: MetaType) => {
try {
if (type === MetaType.DataType) feature.data_types.push(DefinitionDataType.fromJsonString(def));
else if (type === MetaType.FlowType) feature.flow_types.push(FlowType.fromJsonString(def));
else feature.runtime_functions.push(RuntimeFunctionDefinition.fromJsonString(def));
switch (type) {
case MetaType.DataType:
feature.data_types.push(DefinitionDataType.fromJsonString(def));
break
case MetaType.FlowType:
feature.flow_types.push(FlowType.fromJsonString(def));
break
case MetaType.RuntimeFunction:
feature.runtime_functions.push(RuntimeFunctionDefinition.fromJsonString(def));
break
case MetaType.Function:
feature.functions.push(FunctionDefinition.fromJsonString(def));
break
default:
throw new Error(`Unknown MetaType: ${type}`);
}
} catch (err) {
feature.errors.push({
definition: extractIdentifier(def, type),
Expand Down
10 changes: 5 additions & 5 deletions package/reader/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"exclude": ["node_modules", "build", "dist"],
"include": ["node_modules/@code0-tech/tucana/pb/**/*.ts"],
"include": ["src/**/*"],
"types": [
"typePatches"
],
"compilerOptions": {
"lib": ["ESNext"],
"module": "NodeNext",
"target": "ESNext",
"lib": ["es2020"],
"module": "commonjs",
"target": "es2020",
"skipLibCheck": true,
"strict": true,
"paths": {
Expand All @@ -17,7 +17,7 @@
},
"baseUrl": "src/",
"sourceMap": true,
"moduleResolution": "nodenext",
"moduleResolution": "bundler",
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
Expand Down