node-opcua-schemas
Advanced tools
Comparing version 2.1.6 to 2.1.8
@@ -292,6 +292,2 @@ "use strict"; | ||
} | ||
//Xx // the field can be ignore | ||
//Xx if (options[field.name] === undefined) { | ||
//Xx continue; | ||
//Xx } | ||
if (options[switchFieldName] !== undefined) { | ||
@@ -301,3 +297,2 @@ // then options[switchFieldName] must equal | ||
continue; | ||
//xx throw new Error("Invalid " + switchFieldName + " value : expecting " + field.switchValue); | ||
} | ||
@@ -345,3 +340,4 @@ } | ||
if (foundFieldForSwitchValue) { | ||
//xx throw new Error(this.schema.name + ": cannot find field with value " + options[switchFieldName]); | ||
// throw new Error(this.schema.name + ": cannot find field with value " | ||
// + options[switchFieldName]); | ||
} | ||
@@ -348,0 +344,0 @@ else { |
export * from "./parse_binary_xsd"; | ||
export * from "./dynamic_extension_object"; | ||
export * from "./toTypeScript"; |
@@ -8,2 +8,3 @@ "use strict"; | ||
__export(require("./dynamic_extension_object")); | ||
__export(require("./toTypeScript")); | ||
//# sourceMappingURL=index.js.map |
@@ -11,5 +11,5 @@ "use strict"; | ||
const node_opcua_debug_1 = require("node-opcua-debug"); | ||
const node_opcua_factory_1 = require("node-opcua-factory"); | ||
const node_opcua_xml2json_1 = require("node-opcua-xml2json"); | ||
const tools_1 = require("./tools"); | ||
const node_opcua_factory_1 = require("node-opcua-factory"); | ||
const doDebug = node_opcua_debug_1.checkDebugFlag(__filename); | ||
@@ -16,0 +16,0 @@ function w(s, l) { |
{ | ||
"name": "node-opcua-schemas", | ||
"version": "2.1.6", | ||
"version": "2.1.8", | ||
"description": "pure nodejs OPCUA SDK - module -schemas", | ||
@@ -21,3 +21,3 @@ "main": "dist/source/index.js", | ||
"node-opcua-variant": "^2.1.6", | ||
"node-opcua-xml2json": "^2.1.6" | ||
"node-opcua-xml2json": "^2.1.8" | ||
}, | ||
@@ -42,3 +42,3 @@ "devDependencies": { | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "c8e1607923cd5bbb4cd916a5d26d9d8e4948df41" | ||
"gitHead": "a9290b68d48927403e853e438ea9bd1bc6ad3f78" | ||
} |
@@ -13,3 +13,3 @@ /** | ||
FieldCategory, | ||
FieldType, | ||
FieldType, | ||
initialize_field, | ||
@@ -44,3 +44,3 @@ initialize_field_array, | ||
const constructor = createDynamicObjectConstructor(schema, typeDictionary); | ||
if (!constructor) { | ||
@@ -50,3 +50,3 @@ return constructor; | ||
// istanbul ignore next | ||
if(!typeDictionary.hasStructuredType(fieldType)) { | ||
if (!typeDictionary.hasStructuredType(fieldType)) { | ||
@@ -63,3 +63,3 @@ typeDictionary.registerFactory(fieldType, constructor as ConstructorFuncWithSchema); | ||
(constructor as any).encodingDefaultXml = encodingDefaultXml; | ||
typeDictionary.associateWithBinaryEncoding(fieldType,encodingDefaultBinary); | ||
typeDictionary.associateWithBinaryEncoding(fieldType, encodingDefaultBinary); | ||
} | ||
@@ -70,3 +70,3 @@ return constructor; | ||
function encodeArrayOrElement( | ||
field: FieldType, | ||
@@ -146,7 +146,7 @@ obj: any, | ||
function initializeField( | ||
field: FieldType, | ||
thisAny: any, | ||
field: FieldType, | ||
thisAny: any, | ||
options: any, | ||
schema: StructuredTypeSchema, | ||
typeDictionary: TypeDictionary | ||
schema: StructuredTypeSchema, | ||
typeDictionary: TypeDictionary | ||
) { | ||
@@ -189,3 +189,2 @@ | ||
// initialize base class first | ||
@@ -259,4 +258,4 @@ if (schema._baseSchema && schema._baseSchema.fields.length) { | ||
function decodeFields( | ||
thisAny: any, | ||
schema: StructuredTypeSchema, | ||
thisAny: any, | ||
schema: StructuredTypeSchema, | ||
stream: BinaryStream, | ||
@@ -286,3 +285,3 @@ typeDictionary: TypeDictionary | ||
} else { | ||
if (field.category === FieldCategory.complex && (thisAny)[field.name] === undefined) { | ||
if (field.category === FieldCategory.complex && (thisAny)[field.name] === undefined) { | ||
// need to create empty structure for deserialisation | ||
@@ -312,3 +311,3 @@ initializeField(field, thisAny, {}, schema, typeDictionary); | ||
public static schema: StructuredTypeSchema = ExtensionObject.schema; | ||
public static possibleFields: string[] = []; | ||
public static possibleFields: string[] = []; | ||
private readonly _typeDictionary: TypeDictionary; | ||
@@ -352,3 +351,3 @@ private __schema?: StructuredTypeSchema; | ||
possibleFields: string[]; | ||
new(options?: any, schema?: StructuredTypeSchema, typeDictionary?: TypeDictionary): any; | ||
new(options?: any, schema?: StructuredTypeSchema, typeDictionary?: TypeDictionary): any; | ||
} | ||
@@ -390,14 +389,10 @@ | ||
/* istanbul ignore next */ | ||
if (uniqueFieldHasBeenFound && options[field.name] !== undefined) { | ||
if (uniqueFieldHasBeenFound && options[field.name] !== undefined) { | ||
// let try to be helpful for the developper by providing some hint | ||
debugLog(this.schema); | ||
throw new Error("union must have only one choice in "+ JSON.stringify(options) + | ||
"\n found while investigating " + field.name + | ||
"\n switchFieldName = " + switchFieldName); | ||
throw new Error("union must have only one choice in " + JSON.stringify(options) + | ||
"\n found while investigating " + field.name + | ||
"\n switchFieldName = " + switchFieldName); | ||
} | ||
//Xx // the field can be ignore | ||
//Xx if (options[field.name] === undefined) { | ||
//Xx continue; | ||
//Xx } | ||
if (options[switchFieldName] !== undefined) { | ||
@@ -407,3 +402,2 @@ // then options[switchFieldName] must equal | ||
continue; | ||
//xx throw new Error("Invalid " + switchFieldName + " value : expecting " + field.switchValue); | ||
} | ||
@@ -450,6 +444,7 @@ } else { | ||
// it is possible also that the switchfield value do not correspond to a valid field | ||
const foundFieldForSwitchValue = schema.fields.findIndex((f) => | ||
const foundFieldForSwitchValue = schema.fields.findIndex((f) => | ||
f.switchValue !== undefined && f.switchValue === options[switchFieldName]); | ||
if (foundFieldForSwitchValue) { | ||
//xx throw new Error(this.schema.name + ": cannot find field with value " + options[switchFieldName]); | ||
// throw new Error(this.schema.name + ": cannot find field with value " | ||
// + options[switchFieldName]); | ||
} else { | ||
@@ -493,3 +488,3 @@ console.log(this.schema); | ||
const typeDictionary : TypeDictionary = (this.schema as any).$typeDictionary; | ||
const typeDictionary: TypeDictionary = (this.schema as any).$typeDictionary; | ||
@@ -496,0 +491,0 @@ const switchValue = stream.readUInt32(); |
export * from "./parse_binary_xsd"; | ||
export * from "./dynamic_extension_object"; | ||
export * from "./toTypeScript"; |
@@ -10,14 +10,13 @@ /** | ||
import { | ||
EnumerationDefinitionSchema, | ||
EnumerationDefinitionSchema, | ||
FieldInterfaceOptions, | ||
StructuredTypeField, | ||
StructuredTypeOptions, | ||
StructuredTypeSchema, | ||
ConstructorFuncWithSchema | ||
StructuredTypeSchema | ||
} from "node-opcua-factory"; | ||
import { checkDebugFlag } from "node-opcua-debug"; | ||
import { DataTypeFactory } from "node-opcua-factory"; | ||
import { Xml2Json } from "node-opcua-xml2json"; | ||
import { prepareEnumeratedType, prepareStructureType } from "./tools"; | ||
import { DataTypeFactory } from "node-opcua-factory"; | ||
@@ -108,14 +107,13 @@ const doDebug = checkDebugFlag(__filename); | ||
export class TypeDictionary extends DataTypeFactory implements ITypeDictionary { | ||
structuredTypes: { | ||
public structuredTypes: { | ||
[key: string]: StructuredTypeSchema; | ||
}; | ||
enumeratedTypes: { | ||
public enumeratedTypes: { | ||
[key: string]: EnumerationDefinitionSchema; | ||
}; | ||
structuredTypesRaw: { | ||
public structuredTypesRaw: { | ||
[key: string]: StructureTypeRaw; | ||
}; | ||
enumeratedTypesRaw: { | ||
public enumeratedTypesRaw: { | ||
[key: string]: EnumeratedType; | ||
@@ -125,11 +123,9 @@ }; | ||
super(baseDataFactories); | ||
this.structuredTypes= {}; | ||
this.structuredTypesRaw= {}; | ||
this.enumeratedTypes= {}; | ||
this.enumeratedTypesRaw= {}; | ||
this.structuredTypes = {}; | ||
this.structuredTypesRaw = {}; | ||
this.enumeratedTypes = {}; | ||
this.enumeratedTypesRaw = {}; | ||
} | ||
} | ||
} | ||
/* tslint:disable:object-literal-shorthand */ | ||
@@ -298,3 +294,2 @@ const state0: any = { | ||
export function parseBinaryXSD( | ||
@@ -301,0 +296,0 @@ xmlString: string, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123692
23
2088
Updatednode-opcua-xml2json@^2.1.8