@@ -44,7 +44,7 @@ const ValueConstructors: Partial<Record<TypeDefinitionType | string, ValueConstr
4444
4545export class ValueFactory {
4646 public static createFromDefinition ( definition : TypeDefinition ) {
47- const { customType, event, type, unitType } = definition ;
47+ const { customType, event, size , type, unitType } = definition ;
4848
4949 const ValueConstructor =
5050 customType || event ? CustomValue : unitType ? UnitValue : ValueConstructors [ type ] ;
@@ -53,26 +53,26 @@ export class ValueFactory {
5353 case CustomValue :
5454 return new ValueConstructor (
5555 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 ,
5860 ) ;
5961 case EnumValue :
6062 return new ValueConstructor ( definition ) ;
6163 case DoubleValue :
6264 case FloatValue :
6365 case IntegerValue :
6466 case UintValue :
65- return new ( ValueConstructor as NumericValueConstructor ) ( definition . size ) ;
67+ return new ( ValueConstructor as NumericValueConstructor ) ( size ) ;
6668 case BytesValue :
6769 case StringValue :
6870 case TimestampValue :
6971 return new ValueConstructor ( ) ;
7072 case UnitValue :
71- return new ValueConstructor (
72- Configuration . getMeasurementTypeDefinition ( definition . unitType as string ) ,
73- ) ;
73+ return new ValueConstructor ( Configuration . getMeasurementTypeDefinition ( unitType as string ) ) ;
7474 default :
75- throw new Error ( `Unknown value type: ${ definition . type } ` ) ;
75+ throw new Error ( `Unknown value type: ${ type } ` ) ;
7676 }
7777 }
7878}
0 commit comments