import { OpaqueStructure } from "node-opcua-extension-object" ; import { IBasicSession } from "node-opcua-pseudo-session" ; import { DataType , VariantArrayType , Variant } from "node-opcua-variant" ; import { getExtraDataTypeManager } from "./get_extra_data_type_manager" ; import { resolveDynamicExtensionObject } from "./resolve_dynamic_extension_object" ; export interface PseudoDataValue { value : Variant ; } ; export async function promoteOpaqueStructure ( session , dataValues ) { const dataValuesToFix = dataValues . filter ( ( dataValue ) => dataValue . value && dataValue . value . dataType === DataType . ExtensionObject && ( ( dataValue . value . arrayType === VariantArrayType . Scalar && dataValue . value . value instanceof OpaqueStructure ) || ( dataValue . value . arrayType !== VariantArrayType . Scalar && dataValue . value . value && dataValue . value . value . length >= 0 && dataValue . value . value [ 0 ] instanceof OpaqueStructure ) ) ) ; if ( dataValuesToFix . length === 0 ) { return ; } const extraDataTypeManager = await getExtraDataTypeManager ( session ) ; const promises = dataValuesToFix . map ( async ( dataValue ) => { return await resolveDynamicExtensionObject ( session , dataValue . value , extraDataTypeManager ) ; } ) ; await Promise . all ( promises . map ( p => p . catch ( e => e ) ) ) ; }