@code0-tech/definition-reader 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { DataType, DataTypeIdentifier } from '@code0-tech/sagittarius-graphql-types';
2
+ import { DataTypeIdentifier as TucanaDataTypeIdentifier } from '@code0-tech/tucana/pb/shared.data_type_pb.js';
3
+ import { ConstructedDataTypes } from '../parser.js';
4
+ declare function getDataType(identifier: string, constructedDataTypes: ConstructedDataTypes): DataType | null;
5
+ declare function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined, constructedDataTypes: ConstructedDataTypes): DataTypeIdentifier | null;
6
+ export { getDataType, getDataTypeIdentifier };
@@ -0,0 +1,5 @@
1
+ import { FlowType as TucanaFlowType } from '@code0-tech/tucana/pb/shared.flow_definition_pb.js';
2
+ import { FlowType } from '@code0-tech/sagittarius-graphql-types';
3
+ import { ConstructedDataTypes } from '../parser.js';
4
+ declare function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes): FlowType | null;
5
+ export { mapFlowType };
@@ -0,0 +1,5 @@
1
+ import { FunctionDefinition } from '@code0-tech/sagittarius-graphql-types';
2
+ import { RuntimeFunctionDefinition as TucanaFunction } from '@code0-tech/tucana/pb/shared.runtime_function_pb.js';
3
+ import { ConstructedDataTypes } from '../parser.js';
4
+ declare function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): FunctionDefinition | null;
5
+ export { mapFunction };
@@ -0,0 +1,3 @@
1
+ import { Translation } from '@code0-tech/tucana/pb/shared.translation_pb.js';
2
+ import { TranslationConnection } from '@code0-tech/sagittarius-graphql-types';
3
+ export declare function getTranslationConnection(translation: Translation[]): TranslationConnection;
@@ -0,0 +1,10 @@
1
+ import { Feature } from './types.js';
2
+ import { DataType } from '@code0-tech/sagittarius-graphql-types';
3
+ import { DefinitionDataType } from '@code0-tech/tucana/pb/shared.data_type_pb.js';
4
+ export interface ConstructedDataTypes {
5
+ scannedTucanaTypes: DefinitionDataType[];
6
+ constructedDataTypes: DataType[];
7
+ id: number;
8
+ }
9
+ export declare function getID(constructedDataTypes: ConstructedDataTypes): number;
10
+ export declare const Definition: (rootPath: string) => Feature[];
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@code0-tech/definition-reader",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Reader for Code0-Definitions",
5
- "main": "./dist/definition-reader.js",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
6
7
  "type": "module",
7
8
  "scripts": {
8
- "build": "npx vite build && node dist/definition-reader.js"
9
+ "build": "vite build",
10
+ "start": "node ./dist/index.js",
11
+ "build:and:run": "vite build && node ./dist/index.js"
9
12
  },
10
13
  "author": "",
11
14
  "license": "",
@@ -20,15 +23,17 @@
20
23
  },
21
24
  "files": [
22
25
  "dist",
23
- "index.ts",
26
+ "src/index.ts",
24
27
  "src"
25
28
  ],
26
29
  "publishConfig": {
27
30
  "access": "public"
28
31
  },
29
32
  "dependencies": {
30
- "@code0-tech/sagittarius-graphql-types": "^0.0.0-00f33663039d78ad59e95306730878c687de5c48",
31
- "@code0-tech/tucana": "^0.0.37",
32
- "@protobuf-ts/runtime": "^2.11.1"
33
+ "@code0-tech/sagittarius-graphql-types": "^0.0.0-56198dce107a9c09cc5eca0773f239d9c3eba598",
34
+ "@code0-tech/tucana": "^0.0.39",
35
+ "@protobuf-ts/runtime": "^2.11.1",
36
+ "@protobuf-ts/runtime-rpc": "^2.11.1",
37
+ "vite-plugin-dts": "^4.5.4"
33
38
  }
34
39
  }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Definition } from './parser.js';
2
+ export type { Feature } from './types.ts';
@@ -11,10 +11,11 @@ import {
11
11
  import {
12
12
  DataTypeIdentifier as TucanaDataTypeIdentifier,
13
13
  DefinitionDataType_Variant, DefinitionDataTypeRule, GenericMapper_GenericCombinationStrategy
14
- } from "@code0-tech/tucana/pb/shared.data_type_pb.ts"
15
- import {GenericMapper as TucanaGenericMapper} from "@code0-tech/tucana/pb/shared.data_type_pb.ts"
16
- import {ConstructedDataTypes, getID} from "../parser.ts";
17
- import {getTranslationConnection} from "./translation.ts";
14
+ } from "@code0-tech/tucana/pb/shared.data_type_pb.js"
15
+ import {GenericMapper as TucanaGenericMapper} from "@code0-tech/tucana/pb/shared.data_type_pb.js"
16
+ import {ConstructedDataTypes, getID} from "../parser.js";
17
+ import {getTranslationConnection} from "./translation.js";
18
+ import {Value} from "@code0-tech/tucana/pb/shared.struct_pb.js";
18
19
 
19
20
  function getDataType(identifier: string, constructedDataTypes: ConstructedDataTypes): DataType | null {
20
21
  const dataType = constructedDataTypes.constructedDataTypes.find(dt => dt.identifier === identifier)
@@ -67,7 +68,7 @@ function createRules(rule: DefinitionDataTypeRule[], constructedDataTypes: Const
67
68
  }
68
69
  case "itemOfCollection": {
69
70
  const ruleConfig: DataTypeRulesItemOfCollectionConfig = {
70
- items: r.config.itemOfCollection.items, //TODO: This needs to be checked
71
+ items: r.config.itemOfCollection.items.map(valueToJSON),
71
72
  }
72
73
  const rule: DataTypeRule = {
73
74
  variant: DataTypeRulesVariant.ItemOfCollection,
@@ -195,7 +196,7 @@ function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined,
195
196
  type: type
196
197
  }
197
198
  }),
198
- sources: mapper.source.map(id =>
199
+ sourceDataTypeIdentifiers: mapper.source.map(id =>
199
200
  getDataTypeIdentifier(id, constructedDataTypes)
200
201
  ).filter(id => id != null),
201
202
  target: mapper.target,
@@ -224,4 +225,27 @@ function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined,
224
225
  return null;
225
226
  }
226
227
 
228
+ // @ts-ignore
229
+ function valueToJSON(value: Value) {
230
+ switch (value.kind.oneofKind) {
231
+ case "nullValue":
232
+ return null
233
+ case "numberValue":
234
+ return value.kind.numberValue
235
+ case "stringValue":
236
+ return value.kind.stringValue
237
+ case "boolValue":
238
+ return value.kind.boolValue
239
+ case "structValue":
240
+ return Object.fromEntries(
241
+ // @ts-ignore
242
+ Object.entries(value.kind.structValue.fields).map(([k, v]) => {
243
+ return [k, valueToJSON(v)]
244
+ })
245
+ )
246
+ case "listValue":
247
+ return value.kind.listValue.values.map(valueToJSON)
248
+ }
249
+ }
250
+
227
251
  export {getDataType, getDataTypeIdentifier}
@@ -1,7 +1,7 @@
1
- import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.ts"
1
+ import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.js"
2
2
  import {FlowType, FlowTypeSetting} from "@code0-tech/sagittarius-graphql-types";
3
- import {getDataType} from "./dataTypeMapper.ts";
4
- import {ConstructedDataTypes, getID} from "../parser.ts";
3
+ import {getDataType} from "./dataTypeMapper.js";
4
+ import {ConstructedDataTypes, getID} from "../parser.js";
5
5
  import {getTranslationConnection} from "./translation.js";
6
6
 
7
7
  function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes): FlowType | null {
@@ -2,9 +2,9 @@ import {FunctionDefinition, ParameterDefinitionConnection} from "@code0-tech/sag
2
2
  import {
3
3
  RuntimeFunctionDefinition as TucanaFunction,
4
4
  RuntimeParameterDefinition
5
- } from "@code0-tech/tucana/pb/shared.runtime_function_pb.ts";
6
- import {getDataTypeIdentifier} from "./dataTypeMapper.ts";
7
- import {ConstructedDataTypes, getID} from "../parser.ts";
5
+ } from "@code0-tech/tucana/pb/shared.runtime_function_pb.js";
6
+ import {getDataTypeIdentifier} from "./dataTypeMapper.js";
7
+ import {ConstructedDataTypes, getID} from "../parser.js";
8
8
  import {getTranslationConnection} from "./translation.js";
9
9
 
10
10
  function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): FunctionDefinition | null {
@@ -18,6 +18,10 @@ function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): F
18
18
  throwsError: func.throwsError,
19
19
  returnType: getDataTypeIdentifier(func.returnTypeIdentifier, constructed),
20
20
  parameterDefinitions: getParameterDefinitionConnection(func.runtimeParameterDefinitions, constructed),
21
+ runtimeFunctionDefinition: {
22
+ id: `gid://sagittarius/RuntimeFunctionDefinition/${getID(constructed)}`,
23
+ identifier: func.runtimeName
24
+ }
21
25
  }
22
26
  }
23
27
 
@@ -28,9 +32,10 @@ function getParameterDefinitionConnection(def: RuntimeParameterDefinition[], con
28
32
  return {
29
33
  id: `gid://sagittarius/ParameterDefinition/${getID(constructed)}`,
30
34
  names: getTranslationConnection(node.name),
35
+ identifier: node.runtimeName,
31
36
  descriptions: getTranslationConnection(node.description),
32
37
  documentations: getTranslationConnection(node.documentation),
33
- dataType: getDataTypeIdentifier(node.dataTypeIdentifier, constructed)
38
+ dataTypeIdentifier: getDataTypeIdentifier(node.dataTypeIdentifier, constructed)
34
39
  }
35
40
  })
36
41
  }
package/src/parser.ts CHANGED
@@ -1,14 +1,14 @@
1
- import {DefinitionDataType as TucanaDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.ts";
2
- import {Feature} from "./types.ts";
1
+ import {DefinitionDataType as TucanaDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.js";
2
+ import {Feature} from "./types.js";
3
3
  import {readdirSync, readFileSync} from "node:fs";
4
- import {FlowType as TucanaFlowType} from "@code0-tech/tucana/pb/shared.flow_definition_pb.ts";
5
- import {RuntimeFunctionDefinition as TucanaFunction} from "@code0-tech/tucana/pb/shared.runtime_function_pb.ts";
4
+ import {FlowType as TucanaFlowType} from "@code0-tech/tucana/pb/shared.flow_definition_pb.js";
5
+ import {RuntimeFunctionDefinition as TucanaFunction} from "@code0-tech/tucana/pb/shared.runtime_function_pb.js";
6
6
  import path from "node:path";
7
- import {mapFlowType} from "./mapper/flowTypeMapper.ts";
8
- import {mapFunction} from "./mapper/functionMapper.ts";
7
+ import {mapFlowType} from "./mapper/flowTypeMapper.js";
8
+ import {mapFunction} from "./mapper/functionMapper.js";
9
9
  import {DataType} from "@code0-tech/sagittarius-graphql-types";
10
- import {DefinitionDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.ts";
11
- import {getDataType} from "./mapper/dataTypeMapper.ts";
10
+ import {DefinitionDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.js";
11
+ import {getDataType} from "./mapper/dataTypeMapper.js";
12
12
 
13
13
  export interface ConstructedDataTypes {
14
14
  scannedTucanaTypes: DefinitionDataType[]
package/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { Definition } from './src/parser.ts';
2
- export type { Feature } from './src/types.ts';