@code0-tech/definition-reader 0.0.17 → 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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +616 -583
- package/dist/mapper/dataTypeMapper.d.ts +2 -2
- package/dist/mapper/flowTypeMapper.d.ts +2 -2
- package/dist/mapper/functionMapper.d.ts +2 -2
- package/dist/parser.d.ts +2 -2
- package/package.json +7 -4
- package/src/index.ts +1 -1
- package/src/mapper/dataTypeMapper.ts +30 -6
- package/src/mapper/flowTypeMapper.ts +3 -3
- package/src/mapper/functionMapper.ts +9 -4
- package/src/parser.ts +8 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataType, DataTypeIdentifier } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
-
import { DataTypeIdentifier as TucanaDataTypeIdentifier } from '@code0-tech/tucana/pb/shared.data_type_pb.
|
|
3
|
-
import { ConstructedDataTypes } from '../parser.
|
|
2
|
+
import { DataTypeIdentifier as TucanaDataTypeIdentifier } from '@code0-tech/tucana/pb/shared.data_type_pb.js';
|
|
3
|
+
import { ConstructedDataTypes } from '../parser.js';
|
|
4
4
|
declare function getDataType(identifier: string, constructedDataTypes: ConstructedDataTypes): DataType | null;
|
|
5
5
|
declare function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined, constructedDataTypes: ConstructedDataTypes): DataTypeIdentifier | null;
|
|
6
6
|
export { getDataType, getDataTypeIdentifier };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FlowType as TucanaFlowType } from '@code0-tech/tucana/pb/shared.flow_definition_pb.
|
|
1
|
+
import { FlowType as TucanaFlowType } from '@code0-tech/tucana/pb/shared.flow_definition_pb.js';
|
|
2
2
|
import { FlowType } from '@code0-tech/sagittarius-graphql-types';
|
|
3
|
-
import { ConstructedDataTypes } from '../parser.
|
|
3
|
+
import { ConstructedDataTypes } from '../parser.js';
|
|
4
4
|
declare function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes): FlowType | null;
|
|
5
5
|
export { mapFlowType };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FunctionDefinition } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
-
import { RuntimeFunctionDefinition as TucanaFunction } from '@code0-tech/tucana/pb/shared.runtime_function_pb.
|
|
3
|
-
import { ConstructedDataTypes } from '../parser.
|
|
2
|
+
import { RuntimeFunctionDefinition as TucanaFunction } from '@code0-tech/tucana/pb/shared.runtime_function_pb.js';
|
|
3
|
+
import { ConstructedDataTypes } from '../parser.js';
|
|
4
4
|
declare function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): FunctionDefinition | null;
|
|
5
5
|
export { mapFunction };
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Feature } from './types.
|
|
1
|
+
import { Feature } from './types.js';
|
|
2
2
|
import { DataType } from '@code0-tech/sagittarius-graphql-types';
|
|
3
|
-
import { DefinitionDataType } from '@code0-tech/tucana/pb/shared.data_type_pb.
|
|
3
|
+
import { DefinitionDataType } from '@code0-tech/tucana/pb/shared.data_type_pb.js';
|
|
4
4
|
export interface ConstructedDataTypes {
|
|
5
5
|
scannedTucanaTypes: DefinitionDataType[];
|
|
6
6
|
constructedDataTypes: DataType[];
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code0-tech/definition-reader",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Reader for Code0-Definitions",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"start": "node ./dist/index.js",
|
|
11
|
+
"build:and:run": "vite build && node ./dist/index.js"
|
|
10
12
|
},
|
|
11
13
|
"author": "",
|
|
12
14
|
"license": "",
|
|
@@ -28,9 +30,10 @@
|
|
|
28
30
|
"access": "public"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|
|
31
|
-
"@code0-tech/sagittarius-graphql-types": "^0.0.0-
|
|
32
|
-
"@code0-tech/tucana": "^0.0.
|
|
33
|
+
"@code0-tech/sagittarius-graphql-types": "^0.0.0-56198dce107a9c09cc5eca0773f239d9c3eba598",
|
|
34
|
+
"@code0-tech/tucana": "^0.0.39",
|
|
33
35
|
"@protobuf-ts/runtime": "^2.11.1",
|
|
36
|
+
"@protobuf-ts/runtime-rpc": "^2.11.1",
|
|
34
37
|
"vite-plugin-dts": "^4.5.4"
|
|
35
38
|
}
|
|
36
39
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Definition } from './parser.
|
|
1
|
+
export { Definition } from './parser.js';
|
|
2
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.
|
|
15
|
-
import {GenericMapper as TucanaGenericMapper} from "@code0-tech/tucana/pb/shared.data_type_pb.
|
|
16
|
-
import {ConstructedDataTypes, getID} from "../parser.
|
|
17
|
-
import {getTranslationConnection} from "./translation.
|
|
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,
|
|
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
|
-
|
|
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.
|
|
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.
|
|
4
|
-
import {ConstructedDataTypes, getID} from "../parser.
|
|
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.
|
|
6
|
-
import {getDataTypeIdentifier} from "./dataTypeMapper.
|
|
7
|
-
import {ConstructedDataTypes, getID} from "../parser.
|
|
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
|
-
|
|
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.
|
|
2
|
-
import {Feature} from "./types.
|
|
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.
|
|
5
|
-
import {RuntimeFunctionDefinition as TucanaFunction} from "@code0-tech/tucana/pb/shared.runtime_function_pb.
|
|
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.
|
|
8
|
-
import {mapFunction} from "./mapper/functionMapper.
|
|
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.
|
|
11
|
-
import {getDataType} from "./mapper/dataTypeMapper.
|
|
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[]
|