@@ -44,7 +44,7 @@ const ValueConstructors: Partial<Record<TypeDefinitionType | string, ValueConstr
44
44
45
45
export class ValueFactory {
46
46
public static createFromDefinition ( definition : TypeDefinition ) {
47
- const { customType, event, type, unitType } = definition ;
47
+ const { customType, event, size , type, unitType } = definition ;
48
48
49
49
const ValueConstructor =
50
50
customType || event ? CustomValue : unitType ? UnitValue : ValueConstructors [ type ] ;
@@ -53,26 +53,26 @@ export class ValueFactory {
53
53
case CustomValue :
54
54
return new ValueConstructor (
55
55
event
56
- ? Configuration . getEventDefinition ( definition . event as string )
57
- : Configuration . getCustomTypeDefinition ( definition . customType as string ) ,
56
+ ? Configuration . getEventDefinition ( event )
57
+ : customType
58
+ ? Configuration . getCustomTypeDefinition ( customType )
59
+ : definition ,
58
60
) ;
59
61
case EnumValue :
60
62
return new ValueConstructor ( definition ) ;
61
63
case DoubleValue :
62
64
case FloatValue :
63
65
case IntegerValue :
64
66
case UintValue :
65
- return new ( ValueConstructor as NumericValueConstructor ) ( definition . size ) ;
67
+ return new ( ValueConstructor as NumericValueConstructor ) ( size ) ;
66
68
case BytesValue :
67
69
case StringValue :
68
70
case TimestampValue :
69
71
return new ValueConstructor ( ) ;
70
72
case UnitValue :
71
- return new ValueConstructor (
72
- Configuration . getMeasurementTypeDefinition ( definition . unitType as string ) ,
73
- ) ;
73
+ return new ValueConstructor ( Configuration . getMeasurementTypeDefinition ( unitType as string ) ) ;
74
74
default :
75
- throw new Error ( `Unknown value type: ${ definition . type } ` ) ;
75
+ throw new Error ( `Unknown value type: ${ type } ` ) ;
76
76
}
77
77
}
78
78
}
0 commit comments