@code0-tech/definition-reader 0.0.14 → 0.0.16
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/definition-reader.js +3911 -0
- package/index.ts +2 -0
- package/package.json +5 -10
- package/src/mapper/dataTypeMapper.ts +227 -0
- package/src/mapper/flowTypeMapper.ts +35 -0
- package/src/mapper/functionMapper.ts +39 -0
- package/src/mapper/translation.ts +9 -0
- package/src/parser.ts +131 -0
- package/src/types.ts +8 -0
package/index.ts
ADDED
package/package.json
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code0-tech/definition-reader",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Reader for Code0-Definitions",
|
|
5
|
-
"main": "./
|
|
6
|
-
"types": "./build/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"import": "./build/index.js",
|
|
10
|
-
"types": "./build/index.d.ts"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
5
|
+
"main": "./dist/definition-reader.js",
|
|
13
6
|
"type": "module",
|
|
14
7
|
"scripts": {
|
|
15
8
|
"build": "npx vite build && node dist/definition-reader.js"
|
|
@@ -26,7 +19,9 @@
|
|
|
26
19
|
"url": "https://github.com/code0-tech/code0-definition"
|
|
27
20
|
},
|
|
28
21
|
"files": [
|
|
29
|
-
"
|
|
22
|
+
"dist",
|
|
23
|
+
"index.ts",
|
|
24
|
+
"src"
|
|
30
25
|
],
|
|
31
26
|
"publishConfig": {
|
|
32
27
|
"access": "public"
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DataType,
|
|
3
|
+
DataTypeIdentifier, DataTypeRule,
|
|
4
|
+
DataTypeRuleConnection, DataTypeRulesContainsKeyConfig, DataTypeRulesContainsTypeConfig,
|
|
5
|
+
DataTypeRulesInputTypeConfig,
|
|
6
|
+
DataTypeRulesInputTypesConfig,
|
|
7
|
+
DataTypeRulesItemOfCollectionConfig, DataTypeRulesNumberRangeConfig,
|
|
8
|
+
DataTypeRulesParentTypeConfig, DataTypeRulesRegexConfig, DataTypeRulesVariant, DataTypeVariant,
|
|
9
|
+
GenericCombinationStrategyType,
|
|
10
|
+
} from "@code0-tech/sagittarius-graphql-types";
|
|
11
|
+
import {
|
|
12
|
+
DataTypeIdentifier as TucanaDataTypeIdentifier,
|
|
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";
|
|
18
|
+
|
|
19
|
+
function getDataType(identifier: string, constructedDataTypes: ConstructedDataTypes): DataType | null {
|
|
20
|
+
const dataType = constructedDataTypes.constructedDataTypes.find(dt => dt.identifier === identifier)
|
|
21
|
+
if (dataType == undefined) {
|
|
22
|
+
const tucanaDataType = constructedDataTypes.scannedTucanaTypes.find(dt => dt.identifier === identifier)
|
|
23
|
+
if (tucanaDataType == undefined) {
|
|
24
|
+
console.error("Skipping Identifier because it can't be identified:" + identifier)
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
const constructed: DataType = {
|
|
28
|
+
id: `gid://sagittarius/DataType/${getID(constructedDataTypes)}`,
|
|
29
|
+
genericKeys: tucanaDataType.genericKeys,
|
|
30
|
+
identifier: tucanaDataType.identifier,
|
|
31
|
+
name: getTranslationConnection(tucanaDataType.name),
|
|
32
|
+
rules: createRules(tucanaDataType.rules, constructedDataTypes),
|
|
33
|
+
variant: getDataTypeVariant(tucanaDataType.variant),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
constructedDataTypes.constructedDataTypes.push(constructed)
|
|
37
|
+
return constructed;
|
|
38
|
+
}
|
|
39
|
+
return dataType;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function createRules(rule: DefinitionDataTypeRule[], constructedDataTypes: ConstructedDataTypes) : DataTypeRuleConnection {
|
|
43
|
+
return {
|
|
44
|
+
count: rule.length,
|
|
45
|
+
nodes: rule.map(r => {
|
|
46
|
+
switch (r.config.oneofKind) {
|
|
47
|
+
case "containsType": {
|
|
48
|
+
const ruleConfig: DataTypeRulesContainsTypeConfig = {
|
|
49
|
+
dataTypeIdentifier: getDataTypeIdentifier(r.config.containsType.dataTypeIdentifier, constructedDataTypes),
|
|
50
|
+
}
|
|
51
|
+
const rule: DataTypeRule = {
|
|
52
|
+
variant: DataTypeRulesVariant.ContainsType,
|
|
53
|
+
config: ruleConfig
|
|
54
|
+
}
|
|
55
|
+
return rule;
|
|
56
|
+
}
|
|
57
|
+
case "containsKey": {
|
|
58
|
+
const ruleConfig: DataTypeRulesContainsKeyConfig = {
|
|
59
|
+
dataTypeIdentifier: getDataTypeIdentifier(r.config.containsKey.dataTypeIdentifier, constructedDataTypes),
|
|
60
|
+
key: r.config.containsKey.key,
|
|
61
|
+
}
|
|
62
|
+
const rule: DataTypeRule = {
|
|
63
|
+
variant: DataTypeRulesVariant.ContainsKey,
|
|
64
|
+
config: ruleConfig
|
|
65
|
+
}
|
|
66
|
+
return rule;
|
|
67
|
+
}
|
|
68
|
+
case "itemOfCollection": {
|
|
69
|
+
const ruleConfig: DataTypeRulesItemOfCollectionConfig = {
|
|
70
|
+
items: r.config.itemOfCollection.items, //TODO: This needs to be checked
|
|
71
|
+
}
|
|
72
|
+
const rule: DataTypeRule = {
|
|
73
|
+
variant: DataTypeRulesVariant.ItemOfCollection,
|
|
74
|
+
config: ruleConfig
|
|
75
|
+
}
|
|
76
|
+
return rule;
|
|
77
|
+
}
|
|
78
|
+
case "numberRange": {
|
|
79
|
+
const ruleConfig: DataTypeRulesNumberRangeConfig = {
|
|
80
|
+
from: Number(r.config.numberRange.from),
|
|
81
|
+
steps: r.config.numberRange.steps ? Number(r.config.numberRange.steps) : undefined,
|
|
82
|
+
to: Number(r.config.numberRange.to),
|
|
83
|
+
}
|
|
84
|
+
const rule : DataTypeRule = {
|
|
85
|
+
variant: DataTypeRulesVariant.NumberRange,
|
|
86
|
+
config: ruleConfig
|
|
87
|
+
}
|
|
88
|
+
return rule;
|
|
89
|
+
}
|
|
90
|
+
case "regex": {
|
|
91
|
+
const ruleConfig: DataTypeRulesRegexConfig = {
|
|
92
|
+
pattern: r.config.regex.pattern,
|
|
93
|
+
}
|
|
94
|
+
const rule : DataTypeRule = {
|
|
95
|
+
variant: DataTypeRulesVariant.Regex,
|
|
96
|
+
config: ruleConfig
|
|
97
|
+
}
|
|
98
|
+
return rule;
|
|
99
|
+
}
|
|
100
|
+
case "inputTypes": {
|
|
101
|
+
const ruleConfig: DataTypeRulesInputTypesConfig = {
|
|
102
|
+
inputTypes: r.config.inputTypes.inputTypes.map(i => {
|
|
103
|
+
console.log("AF: " + i.inputIdentifier)
|
|
104
|
+
const input: DataTypeRulesInputTypeConfig = {
|
|
105
|
+
dataTypeIdentifier: getDataTypeIdentifier(i.dataTypeIdentifier, constructedDataTypes),
|
|
106
|
+
inputIdentifier: i.inputIdentifier,
|
|
107
|
+
}
|
|
108
|
+
return input;
|
|
109
|
+
}),
|
|
110
|
+
}
|
|
111
|
+
const rule : DataTypeRule = {
|
|
112
|
+
variant: DataTypeRulesVariant.InputType,
|
|
113
|
+
config: ruleConfig
|
|
114
|
+
}
|
|
115
|
+
return rule;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case "returnType": {
|
|
119
|
+
const ruleConfig: DataTypeRulesParentTypeConfig = {
|
|
120
|
+
dataTypeIdentifier: getDataTypeIdentifier(r.config.returnType.dataTypeIdentifier, constructedDataTypes),
|
|
121
|
+
}
|
|
122
|
+
const rule : DataTypeRule = {
|
|
123
|
+
variant: DataTypeRulesVariant.ReturnType,
|
|
124
|
+
config: ruleConfig
|
|
125
|
+
}
|
|
126
|
+
return rule;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
case "parentType": {
|
|
130
|
+
const ruleConfig: DataTypeRulesParentTypeConfig = {
|
|
131
|
+
dataTypeIdentifier: getDataTypeIdentifier(r.config.parentType.parentType, constructedDataTypes),
|
|
132
|
+
}
|
|
133
|
+
const rule : DataTypeRule = {
|
|
134
|
+
variant: DataTypeRulesVariant.ParentType,
|
|
135
|
+
config: ruleConfig
|
|
136
|
+
}
|
|
137
|
+
return rule;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
throw new Error(`Unknown rule: ${rule}`)
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getDataTypeVariant(variant: DefinitionDataType_Variant): DataTypeVariant {
|
|
147
|
+
switch (variant) {
|
|
148
|
+
case DefinitionDataType_Variant.ARRAY:
|
|
149
|
+
return DataTypeVariant.Array
|
|
150
|
+
case DefinitionDataType_Variant.DATATYPE:
|
|
151
|
+
return DataTypeVariant.DataType;
|
|
152
|
+
case DefinitionDataType_Variant.ERROR:
|
|
153
|
+
return DataTypeVariant.Error;
|
|
154
|
+
case DefinitionDataType_Variant.NODE:
|
|
155
|
+
return DataTypeVariant.Node;
|
|
156
|
+
case DefinitionDataType_Variant.OBJECT:
|
|
157
|
+
return DataTypeVariant.Object;
|
|
158
|
+
case DefinitionDataType_Variant.PRIMITIVE:
|
|
159
|
+
return DataTypeVariant.Primitive;
|
|
160
|
+
case DefinitionDataType_Variant.TYPE:
|
|
161
|
+
return DataTypeVariant.Type;
|
|
162
|
+
default:
|
|
163
|
+
throw new Error(`Unknown variant: ${variant}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function getDataTypeIdentifier(identifier: TucanaDataTypeIdentifier | undefined, constructedDataTypes: ConstructedDataTypes): DataTypeIdentifier | null {
|
|
168
|
+
if (identifier == undefined) {
|
|
169
|
+
return null
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
switch (identifier.type.oneofKind) {
|
|
173
|
+
case "genericType": {
|
|
174
|
+
return {
|
|
175
|
+
id: `gid://sagittarius/DataTypeIdentifier/${getID(constructedDataTypes)}`,
|
|
176
|
+
genericType: {
|
|
177
|
+
id: `gid://sagittarius/GenericType/${getID(constructedDataTypes)}`,
|
|
178
|
+
dataType: getDataType(identifier.type.genericType.dataTypeIdentifier, constructedDataTypes),
|
|
179
|
+
genericMappers: identifier.type.genericType.genericMappers.map((mapper: TucanaGenericMapper) => {
|
|
180
|
+
return {
|
|
181
|
+
genericCombinationStrategies: mapper.genericCombinations.map(m => {
|
|
182
|
+
let type = undefined
|
|
183
|
+
switch (m) {
|
|
184
|
+
case GenericMapper_GenericCombinationStrategy.AND:
|
|
185
|
+
type = GenericCombinationStrategyType.And
|
|
186
|
+
break
|
|
187
|
+
case GenericMapper_GenericCombinationStrategy.OR:
|
|
188
|
+
type = GenericCombinationStrategyType.Or
|
|
189
|
+
break
|
|
190
|
+
default:
|
|
191
|
+
throw new Error("GenericCombinationStrategy was Unknown");
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
id: `gid://sagittarius/GenericCombinationStrategy/${getID(constructedDataTypes)}`,
|
|
195
|
+
type: type
|
|
196
|
+
}
|
|
197
|
+
}),
|
|
198
|
+
sources: mapper.source.map(id =>
|
|
199
|
+
getDataTypeIdentifier(id, constructedDataTypes)
|
|
200
|
+
).filter(id => id != null),
|
|
201
|
+
target: mapper.target,
|
|
202
|
+
id: `gid://sagittarius/GenericMapper/${getID(constructedDataTypes)}`,
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
case "dataTypeIdentifier": {
|
|
210
|
+
return {
|
|
211
|
+
id: `gid://sagittarius/DataTypeIdentifier/${getID(constructedDataTypes)}`,
|
|
212
|
+
dataType: getDataType(identifier.type.dataTypeIdentifier, constructedDataTypes)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
case "genericKey": {
|
|
217
|
+
return {
|
|
218
|
+
id: `gid://sagittarius/DataTypeIdentifier/${getID(constructedDataTypes)}`,
|
|
219
|
+
genericKey: identifier.type.genericKey,
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export {getDataType, getDataTypeIdentifier}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {FlowType as TucanaFlowType, FlowTypeSetting as TucanaFlowTypeSetting} from "@code0-tech/tucana/pb/shared.flow_definition_pb.ts"
|
|
2
|
+
import {FlowType, FlowTypeSetting} from "@code0-tech/sagittarius-graphql-types";
|
|
3
|
+
import {getDataType} from "./dataTypeMapper.ts";
|
|
4
|
+
import {ConstructedDataTypes, getID} from "../parser.ts";
|
|
5
|
+
import {getTranslationConnection} from "./translation.js";
|
|
6
|
+
|
|
7
|
+
function mapFlowType(flowType: TucanaFlowType, constructed: ConstructedDataTypes): FlowType | null {
|
|
8
|
+
return {
|
|
9
|
+
id: `gid://sagittarius/TypesFlowType/${getID(constructed)}`,
|
|
10
|
+
identifier: flowType.identifier,
|
|
11
|
+
inputType: getDataType(flowType.inputTypeIdentifier!!, constructed),
|
|
12
|
+
returnType: getDataType(flowType.returnTypeIdentifier!!, constructed),
|
|
13
|
+
flowTypeSettings: createFlowTypeSetting(flowType.settings, constructed),
|
|
14
|
+
names: getTranslationConnection(flowType.name),
|
|
15
|
+
descriptions: getTranslationConnection(flowType.description),
|
|
16
|
+
editable: flowType.editable
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function createFlowTypeSetting(settings: TucanaFlowTypeSetting[], constructed: ConstructedDataTypes): FlowTypeSetting[] {
|
|
21
|
+
return settings.map(setting => {
|
|
22
|
+
const flowSetting: FlowTypeSetting = {
|
|
23
|
+
id: `gid://sagittarius/FlowTypeSetting/${getID(constructed)}`,
|
|
24
|
+
names: getTranslationConnection(setting.name),
|
|
25
|
+
descriptions: getTranslationConnection(setting.description),
|
|
26
|
+
dataType: getDataType(setting.dataTypeIdentifier, constructed),
|
|
27
|
+
identifier: setting.identifier,
|
|
28
|
+
unique: setting.unique
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return flowSetting;
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {mapFlowType}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {FunctionDefinition, ParameterDefinitionConnection} from "@code0-tech/sagittarius-graphql-types";
|
|
2
|
+
import {
|
|
3
|
+
RuntimeFunctionDefinition as TucanaFunction,
|
|
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";
|
|
8
|
+
import {getTranslationConnection} from "./translation.js";
|
|
9
|
+
|
|
10
|
+
function mapFunction(func: TucanaFunction, constructed: ConstructedDataTypes): FunctionDefinition | null {
|
|
11
|
+
return {
|
|
12
|
+
id: `gid://sagittarius/FunctionDefinition/${getID(constructed)}`,
|
|
13
|
+
genericKeys: func.genericKeys,
|
|
14
|
+
names: getTranslationConnection(func.name),
|
|
15
|
+
descriptions: getTranslationConnection(func.description),
|
|
16
|
+
documentations: getTranslationConnection(func.documentation),
|
|
17
|
+
deprecationMessages: getTranslationConnection(func.deprecationMessage),
|
|
18
|
+
throwsError: func.throwsError,
|
|
19
|
+
returnType: getDataTypeIdentifier(func.returnTypeIdentifier, constructed),
|
|
20
|
+
parameterDefinitions: getParameterDefinitionConnection(func.runtimeParameterDefinitions, constructed),
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getParameterDefinitionConnection(def: RuntimeParameterDefinition[], constructed: ConstructedDataTypes): ParameterDefinitionConnection {
|
|
25
|
+
return {
|
|
26
|
+
count: def.length,
|
|
27
|
+
nodes: def.map(node => {
|
|
28
|
+
return {
|
|
29
|
+
id: `gid://sagittarius/ParameterDefinition/${getID(constructed)}`,
|
|
30
|
+
names: getTranslationConnection(node.name),
|
|
31
|
+
descriptions: getTranslationConnection(node.description),
|
|
32
|
+
documentations: getTranslationConnection(node.documentation),
|
|
33
|
+
dataType: getDataTypeIdentifier(node.dataTypeIdentifier, constructed)
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {mapFunction}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {Translation} from "@code0-tech/tucana/pb/shared.translation_pb.js";
|
|
2
|
+
import {TranslationConnection} from "@code0-tech/sagittarius-graphql-types";
|
|
3
|
+
|
|
4
|
+
export function getTranslationConnection(translation: Translation[]): TranslationConnection {
|
|
5
|
+
return {
|
|
6
|
+
count: translation.length,
|
|
7
|
+
nodes: translation,
|
|
8
|
+
}
|
|
9
|
+
}
|
package/src/parser.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import {DefinitionDataType as TucanaDataType} from "@code0-tech/tucana/pb/shared.data_type_pb.ts";
|
|
2
|
+
import {Feature} from "./types.ts";
|
|
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";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import {mapFlowType} from "./mapper/flowTypeMapper.ts";
|
|
8
|
+
import {mapFunction} from "./mapper/functionMapper.ts";
|
|
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";
|
|
12
|
+
|
|
13
|
+
export interface ConstructedDataTypes {
|
|
14
|
+
scannedTucanaTypes: DefinitionDataType[]
|
|
15
|
+
constructedDataTypes: DataType[]
|
|
16
|
+
id: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getID(constructedDataTypes: ConstructedDataTypes) {
|
|
20
|
+
const last = constructedDataTypes.id
|
|
21
|
+
constructedDataTypes.id += 1
|
|
22
|
+
return last
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Definition = (rootPath: string): Feature[] => {
|
|
26
|
+
const dataTypes: {feature: string, type: TucanaDataType}[] = []
|
|
27
|
+
const runtimeFunctions: {feature: string, func: TucanaFunction}[] = [];
|
|
28
|
+
const flowTypes: {feature: string, flow: TucanaFlowType}[] = [];
|
|
29
|
+
|
|
30
|
+
readdirSync(rootPath, { withFileTypes: true }).forEach(file => {
|
|
31
|
+
const featureName = file.name.split("_")[0]
|
|
32
|
+
if (featureName == null) {
|
|
33
|
+
throw new Error("Feature name is null")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const filePath = path.join(file.parentPath, file.name)
|
|
37
|
+
|
|
38
|
+
const content = readFileSync(filePath);
|
|
39
|
+
if (file.name.includes("data_type")) {
|
|
40
|
+
const decoded = TucanaDataType.fromBinary(content);
|
|
41
|
+
dataTypes.push(
|
|
42
|
+
{
|
|
43
|
+
feature: featureName,
|
|
44
|
+
type: decoded,
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (file.name.includes("function")) {
|
|
50
|
+
const decoded = TucanaFunction.fromBinary(content);
|
|
51
|
+
runtimeFunctions.push(
|
|
52
|
+
{
|
|
53
|
+
feature: featureName,
|
|
54
|
+
func: decoded,
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (file.name.includes("flow_type")) {
|
|
60
|
+
const decoded = TucanaFlowType.fromBinary(content);
|
|
61
|
+
flowTypes.push(
|
|
62
|
+
{
|
|
63
|
+
feature: featureName,
|
|
64
|
+
flow: decoded,
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const features: Feature[] = []
|
|
71
|
+
const constructed: ConstructedDataTypes = {
|
|
72
|
+
scannedTucanaTypes: dataTypes.map(f => f.type),
|
|
73
|
+
constructedDataTypes: [],
|
|
74
|
+
id: 0
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function getFeature(name:string): Feature {
|
|
78
|
+
const feature = features.find((f) => f.name === name);
|
|
79
|
+
if (feature != undefined) {
|
|
80
|
+
return feature;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const newFeature = {
|
|
84
|
+
name: name,
|
|
85
|
+
dataTypes: [],
|
|
86
|
+
flowTypes: [],
|
|
87
|
+
runtimeFunctions: [],
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
features.push(newFeature);
|
|
91
|
+
return newFeature;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
dataTypes.map(f => {
|
|
95
|
+
return {
|
|
96
|
+
name: f.feature,
|
|
97
|
+
type: getDataType(f.type.identifier, constructed)
|
|
98
|
+
}
|
|
99
|
+
}).forEach(dt => {
|
|
100
|
+
if (dt.type != null) {
|
|
101
|
+
const feature = getFeature(dt.name)
|
|
102
|
+
feature.dataTypes.push(dt.type)
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
runtimeFunctions.map(f => {
|
|
107
|
+
return {
|
|
108
|
+
name: f.feature,
|
|
109
|
+
type: mapFunction(f.func, constructed)
|
|
110
|
+
}
|
|
111
|
+
}).forEach(dt => {
|
|
112
|
+
if (dt.type != null) {
|
|
113
|
+
const feature = getFeature(dt.name)
|
|
114
|
+
feature.runtimeFunctions.push(dt.type)
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
flowTypes.map(f => {
|
|
119
|
+
return {
|
|
120
|
+
name: f.feature,
|
|
121
|
+
type: mapFlowType(f.flow, constructed)
|
|
122
|
+
}
|
|
123
|
+
}).forEach(dt => {
|
|
124
|
+
if (dt.type != null) {
|
|
125
|
+
const feature = getFeature(dt.name)
|
|
126
|
+
feature.flowTypes.push(dt.type)
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
return features;
|
|
131
|
+
}
|