node-opcua-factory
Advanced tools
Comparing version 2.11.0 to 2.13.0
@@ -69,4 +69,11 @@ "use strict"; | ||
returnValue = factories_enumerations_1.getEnumeration(fieldTypeWithoutNS); | ||
throw new Error("Cannot find Schema for field with name " + field.name + " fieldTypeWithoutNS= " + fieldTypeWithoutNS + | ||
" with type " + field.fieldType + " category = " + category + JSON.stringify(field, null, "\t")); | ||
throw new Error("Cannot find Schema for field with name " + | ||
field.name + | ||
" fieldTypeWithoutNS= " + | ||
fieldTypeWithoutNS + | ||
" with type " + | ||
field.fieldType + | ||
" category = " + | ||
category + | ||
JSON.stringify(field, null, "\t")); | ||
} | ||
@@ -81,3 +88,7 @@ return returnValue; | ||
throw new Error("expecting a valid schema for field with name " + | ||
fieldLight.name + " with type " + fieldLight.fieldType + " category" + category); | ||
fieldLight.name + | ||
" with type " + | ||
fieldLight.fieldType + | ||
" category" + | ||
category); | ||
} | ||
@@ -124,4 +135,9 @@ return { | ||
for (const f of this.fields) { | ||
str.push(" field = " + f.name.padEnd(30) + " isArray= " + (f.isArray ? true : false) + " " + f.fieldType.toString().padEnd(30) + | ||
(f.switchBit !== undefined ? (" switchBit " + f.switchBit) : "") + | ||
str.push(" field = " + | ||
f.name.padEnd(30) + | ||
" isArray= " + | ||
(f.isArray ? true : false) + | ||
" " + | ||
f.fieldType.toString().padEnd(30) + | ||
(f.switchBit !== undefined ? " switchBit " + f.switchBit : "") + | ||
(f.switchValue !== undefined ? " switchValue " + f.switchValue : "")); | ||
@@ -152,2 +168,5 @@ } | ||
if (schema.baseType && schema.baseType !== "BaseUAObject" && schema.baseType !== "DataTypeDefinition") { | ||
if (!factories_factories_1.hasStructuredType(schema.baseType)) { | ||
return null; | ||
} | ||
const baseType = factories_factories_1.getStructureTypeConstructor(schema.baseType); | ||
@@ -204,9 +223,8 @@ // istanbul ignore next | ||
// istanbul ignore next | ||
if (!_.isObject(options) && !(typeof (options) === "object")) { | ||
let message = chalk.red(" Invalid options specified while trying to construct a ") | ||
+ " " + chalk.yellow(schema.name); | ||
if (!_.isObject(options) && !(typeof options === "object")) { | ||
let message = chalk.red(" Invalid options specified while trying to construct a ") + " " + chalk.yellow(schema.name); | ||
message += "\n"; | ||
message += chalk.red(" expecting a ") + chalk.yellow(" Object "); | ||
message += "\n"; | ||
message += chalk.red(" and got a ") + chalk.yellow((typeof options)) + chalk.red(" instead "); | ||
message += chalk.red(" and got a ") + chalk.yellow(typeof options) + chalk.red(" instead "); | ||
// console.log(" Schema = ", schema); | ||
@@ -213,0 +231,0 @@ // console.log(" options = ", options); |
{ | ||
"name": "node-opcua-factory", | ||
"version": "2.11.0", | ||
"version": "2.13.0", | ||
"description": "pure nodejs OPCUA SDK - module -factory", | ||
@@ -16,3 +16,3 @@ "main": "./dist/index.js", | ||
"node-opcua-assert": "2.10.0", | ||
"node-opcua-basic-types": "2.11.0", | ||
"node-opcua-basic-types": "2.13.0", | ||
"node-opcua-binary-stream": "2.11.0", | ||
@@ -24,3 +24,3 @@ "node-opcua-debug": "2.10.0", | ||
"node-opcua-status-code": "2.11.0", | ||
"node-opcua-utils": "2.10.0", | ||
"node-opcua-utils": "2.13.0", | ||
"underscore": "^1.10.2" | ||
@@ -43,3 +43,3 @@ }, | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "1e1c6d63340aa799867af261437a6a0f5a9a2cdd" | ||
"gitHead": "3c8a33e1e9d7923c9434607ad22d51d6d8d58918" | ||
} |
@@ -5,12 +5,5 @@ /** | ||
import * as chalk from "chalk"; | ||
import * as _ from "underscore"; | ||
import * as _ from "underscore"; | ||
import { | ||
CommonInterface, | ||
FieldCategory, | ||
FieldInterfaceOptions, | ||
FieldType, | ||
StructuredTypeOptions, | ||
TypeSchemaBase | ||
} from "./types"; | ||
import { CommonInterface, FieldCategory, FieldInterfaceOptions, FieldType, StructuredTypeOptions, TypeSchemaBase } from "./types"; | ||
@@ -28,5 +21,3 @@ import { assert } from "node-opcua-assert"; | ||
function figureOutFieldCategory( | ||
field: FieldInterfaceOptions | ||
): FieldCategory { | ||
function figureOutFieldCategory(field: FieldInterfaceOptions): FieldCategory { | ||
const fieldType = field.fieldType; | ||
@@ -56,3 +47,2 @@ | ||
): CommonInterface { | ||
if (field.schema) { | ||
@@ -94,4 +84,13 @@ return field.schema; | ||
returnValue = getEnumeration(fieldTypeWithoutNS); | ||
throw new Error("Cannot find Schema for field with name " + field.name + " fieldTypeWithoutNS= " + fieldTypeWithoutNS + | ||
" with type " + field.fieldType + " category = " + category + JSON.stringify(field, null, "\t")); | ||
throw new Error( | ||
"Cannot find Schema for field with name " + | ||
field.name + | ||
" fieldTypeWithoutNS= " + | ||
fieldTypeWithoutNS + | ||
" with type " + | ||
field.fieldType + | ||
" category = " + | ||
category + | ||
JSON.stringify(field, null, "\t") | ||
); | ||
} | ||
@@ -102,3 +101,2 @@ return returnValue; | ||
function buildField(underConstructSchema: StructuredTypeSchema, fieldLight: FieldInterfaceOptions): FieldType { | ||
const category = figureOutFieldCategory(fieldLight); | ||
@@ -109,4 +107,10 @@ const schema = figureOutSchema(underConstructSchema, fieldLight, category); | ||
if (!schema) { | ||
throw new Error("expecting a valid schema for field with name " + | ||
fieldLight.name + " with type " + fieldLight.fieldType + " category" + category); | ||
throw new Error( | ||
"expecting a valid schema for field with name " + | ||
fieldLight.name + | ||
" with type " + | ||
fieldLight.fieldType + | ||
" category" + | ||
category | ||
); | ||
} | ||
@@ -133,3 +137,2 @@ | ||
export class StructuredTypeSchema extends TypeSchemaBase { | ||
public fields: FieldType[]; | ||
@@ -175,3 +178,2 @@ public id: NodeId; | ||
public toString() { | ||
const str: string[] = []; | ||
@@ -188,8 +190,14 @@ str.push("name = " + this.name); | ||
for (const f of this.fields) { | ||
str.push(" field = " + f.name.padEnd(30) + " isArray= " + (f.isArray ? true : false) + " " + f.fieldType.toString().padEnd(30) + | ||
(f.switchBit !== undefined ? (" switchBit " + f.switchBit) : "") + | ||
(f.switchValue !== undefined ? " switchValue " + f.switchValue : "")); | ||
str.push( | ||
" field = " + | ||
f.name.padEnd(30) + | ||
" isArray= " + | ||
(f.isArray ? true : false) + | ||
" " + | ||
f.fieldType.toString().padEnd(30) + | ||
(f.switchBit !== undefined ? " switchBit " + f.switchBit : "") + | ||
(f.switchValue !== undefined ? " switchValue " + f.switchValue : "") | ||
); | ||
} | ||
return str.join("\n"); | ||
} | ||
@@ -206,3 +214,2 @@ } | ||
export function get_base_schema(schema: StructuredTypeSchema) { | ||
let baseSchema = schema._baseSchema; | ||
@@ -221,2 +228,5 @@ if (baseSchema) { | ||
if (schema.baseType && schema.baseType !== "BaseUAObject" && schema.baseType !== "DataTypeDefinition") { | ||
if (!hasStructuredType(schema.baseType)) { | ||
return null; | ||
} | ||
const baseType = getStructureTypeConstructor(schema.baseType); | ||
@@ -244,3 +254,2 @@ | ||
export function extract_all_fields(schema: StructuredTypeSchema) { | ||
// returns cached result if any | ||
@@ -274,3 +283,2 @@ // istanbul ignore next | ||
export function check_options_correctness_against_schema(obj: any, schema: StructuredTypeSchema, options: any): boolean { | ||
if (!parameters.debugSchemaHelper) { | ||
@@ -283,9 +291,8 @@ return true; // ignoring set | ||
// istanbul ignore next | ||
if (!_.isObject(options) && !(typeof (options) === "object")) { | ||
let message = chalk.red(" Invalid options specified while trying to construct a ") | ||
+ " " + chalk.yellow(schema.name); | ||
if (!_.isObject(options) && !(typeof options === "object")) { | ||
let message = chalk.red(" Invalid options specified while trying to construct a ") + " " + chalk.yellow(schema.name); | ||
message += "\n"; | ||
message += chalk.red(" expecting a ") + chalk.yellow(" Object "); | ||
message += "\n"; | ||
message += chalk.red(" and got a ") + chalk.yellow((typeof options)) + chalk.red(" instead "); | ||
message += chalk.red(" and got a ") + chalk.yellow(typeof options) + chalk.red(" instead "); | ||
// console.log(" Schema = ", schema); | ||
@@ -292,0 +299,0 @@ // console.log(" options = ", options); |
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
236900
4380
+ Addednode-opcua-basic-types@2.13.0(transitive)
+ Addednode-opcua-utils@2.13.0(transitive)
- Removednode-opcua-basic-types@2.11.0(transitive)
- Removednode-opcua-utils@2.10.0(transitive)
Updatednode-opcua-utils@2.13.0