node-opcua-generator
Advanced tools
Comparing version 2.72.2 to 2.73.0
/** | ||
* @module node-opcua-generator | ||
*/ | ||
import { StructuredTypeSchema } from "node-opcua-factory"; | ||
import { IStructuredTypeSchema } from "node-opcua-factory"; | ||
import { WriteFunc } from "./utils/write_func"; | ||
export declare function get_class_TScript_filename(schemaName: string, optionalFolder?: string): string; | ||
export declare function get_class_JScript_filename(schemaName: string, optionalFolder?: string): string; | ||
export declare function writeStructuredType(write: WriteFunc, schema: StructuredTypeSchema): void; | ||
export declare function produce_TScript_code(schema: StructuredTypeSchema, localSchemaFile: string, generatedTypescriptFilename: string): void; | ||
export declare function writeStructuredType(write: WriteFunc, schema: IStructuredTypeSchema): void; | ||
export declare function produce_TScript_code(schema: IStructuredTypeSchema, localSchemaFile: string, generatedTypescriptFilename: string): void; |
@@ -184,2 +184,3 @@ "use strict"; | ||
break; | ||
case "String": | ||
case "UAString": | ||
@@ -511,3 +512,3 @@ write(` this.${member} = null;`); | ||
case node_opcua_factory_1.FieldCategory.enumeration: { | ||
write(` ${member}?: ${field.fieldType}${arrayOpt};`); | ||
write(` ${member}?: ${toJavascriptType(field.fieldType)}${arrayOpt};`); | ||
break; | ||
@@ -517,6 +518,6 @@ } | ||
if (field.fieldType === "ExtensionObject") { | ||
write(` ${member}?: (${field.fieldType} | null)${arrayOpt};`); | ||
write(` ${member}?: (${toJavascriptType(field.fieldType)} | null)${arrayOpt};`); | ||
} | ||
else if (field.fieldType === "DiagnosticInfo") { | ||
write(` ${member}?: (${field.fieldType} | null)${arrayOpt};`); | ||
write(` ${member}?: (${toJavascriptType(field.fieldType)} | null)${arrayOpt};`); | ||
} | ||
@@ -528,6 +529,6 @@ else if (field.fieldType === "Variant" || | ||
field.fieldType === "LocalizedText") { | ||
write(` ${member}?: (${field.fieldType}Like | null)${arrayOpt};`); | ||
write(` ${member}?: (${toJavascriptType(field.fieldType)}Like | null)${arrayOpt};`); | ||
} | ||
else { | ||
write(` ${member}?: ${field.fieldType} ${arrayOpt};`); | ||
write(` ${member}?: ${toJavascriptType(field.fieldType)} ${arrayOpt};`); | ||
} | ||
@@ -543,2 +544,12 @@ break; | ||
} | ||
function toJavascriptType(fieldType) { | ||
switch (fieldType) { | ||
case "String": | ||
return "UAString"; | ||
case "Boolean": | ||
return "UABoolean"; | ||
default: | ||
return fieldType; | ||
} | ||
} | ||
function write_declare_class_member(write, schema) { | ||
@@ -552,3 +563,3 @@ const n = schema.fields.length; | ||
case node_opcua_factory_1.FieldCategory.enumeration: { | ||
write(` public ${member}: ${field.fieldType}${arrayOpt};`); | ||
write(` public ${member}: ${toJavascriptType(field.fieldType)}${arrayOpt};`); | ||
break; | ||
@@ -558,9 +569,9 @@ } | ||
if (field.fieldType === "DiagnosticInfo") { | ||
write(` public ${member}: (${field.fieldType} | null)${arrayOpt};`); | ||
write(` public ${member}: (${toJavascriptType(field.fieldType)} | null)${arrayOpt};`); | ||
} | ||
else if (field.fieldType === "ExtensionObject") { | ||
write(` public ${member}: (${field.fieldType} | null)${arrayOpt};`); | ||
write(` public ${member}: (${toJavascriptType(field.fieldType)} | null)${arrayOpt};`); | ||
} | ||
else { | ||
write(` public ${member}: ${field.fieldType}${arrayOpt};`); | ||
write(` public ${member}: ${toJavascriptType(field.fieldType)}${arrayOpt};`); | ||
} | ||
@@ -570,3 +581,3 @@ break; | ||
case node_opcua_factory_1.FieldCategory.complex: { | ||
write(` public ${member}: ${field.fieldType}${arrayOpt};`); | ||
write(` public ${member}: ${toJavascriptType(field.fieldType)}${arrayOpt};`); | ||
break; | ||
@@ -622,3 +633,3 @@ } | ||
field.fieldType + | ||
': (value: any, stream: OutputBinaryStream) => void = getBuildInType("' + | ||
': (value: any, stream: OutputBinaryStream) => void = getBuiltInType("' + | ||
field.fieldType + | ||
@@ -628,3 +639,3 @@ '").encode;'); | ||
field.fieldType + | ||
': (stream: BinaryStream) => void = getBuildInType("' + | ||
': (stream: BinaryStream) => void = getBuiltInType("' + | ||
field.fieldType + | ||
@@ -755,3 +766,3 @@ '").decode;'); | ||
write(` generate_new_id,`); | ||
write(` getBuildInType,`); | ||
write(` getBuiltInType,`); | ||
write(` registerClassDefinition,`); | ||
@@ -758,0 +769,0 @@ write(` getStructuredTypeSchema,`); |
@@ -293,3 +293,3 @@ "use strict"; | ||
} | ||
processStructuredType(dataTypeFactory.getStructuredTypeSchema("LocalizedText")); | ||
//xx processStructuredType(dataTypeFactory.getStructuredTypeSchema("LocalizedText")); | ||
processStructuredType(dataTypeFactory.getStructuredTypeSchema("AxisInformation")); | ||
@@ -296,0 +296,0 @@ // processStructuredType(dataTypeFactory.getStructuredTypeSchema("DiagnosticInfo")); |
{ | ||
"name": "node-opcua-generator", | ||
"version": "2.72.2", | ||
"version": "2.73.0", | ||
"description": "pure nodejs OPCUA SDK - module -generator", | ||
@@ -17,24 +17,24 @@ "main": "./dist/index.js", | ||
"node-opcua-assert": "2.66.0", | ||
"node-opcua-basic-types": "2.72.1", | ||
"node-opcua-basic-types": "2.73.0", | ||
"node-opcua-buffer-utils": "2.71.0", | ||
"node-opcua-constants": "2.70.0", | ||
"node-opcua-data-model": "2.72.1", | ||
"node-opcua-data-value": "2.72.2", | ||
"node-opcua-date-time": "2.71.0", | ||
"node-opcua-data-model": "2.73.0", | ||
"node-opcua-data-value": "2.73.0", | ||
"node-opcua-date-time": "2.73.0", | ||
"node-opcua-debug": "2.71.0", | ||
"node-opcua-enum": "2.71.0", | ||
"node-opcua-factory": "2.72.1", | ||
"node-opcua-factory": "2.73.0", | ||
"node-opcua-guid": "2.66.0", | ||
"node-opcua-nodeid": "2.71.0", | ||
"node-opcua-numeric-range": "2.72.2", | ||
"node-opcua-schemas": "2.72.2", | ||
"node-opcua-status-code": "2.71.0", | ||
"node-opcua-numeric-range": "2.73.0", | ||
"node-opcua-schemas": "2.73.0", | ||
"node-opcua-status-code": "2.73.0", | ||
"node-opcua-utils": "2.71.0", | ||
"node-opcua-variant": "2.72.2", | ||
"node-opcua-xml2json": "2.71.0" | ||
"node-opcua-variant": "2.73.0", | ||
"node-opcua-xml2json": "2.73.0" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-binary-stream": "2.71.0", | ||
"node-opcua-extension-object": "2.72.1", | ||
"node-opcua-packet-analyzer": "2.72.1", | ||
"node-opcua-binary-stream": "2.73.0", | ||
"node-opcua-extension-object": "2.73.0", | ||
"node-opcua-packet-analyzer": "2.73.0", | ||
"prettier": "^2.7.1", | ||
@@ -60,3 +60,3 @@ "should": "^13.2.3", | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c" | ||
"gitHead": "b23a87c1ef777c0d8b680f45ee77e2a319feb092" | ||
} |
@@ -20,3 +20,3 @@ /* istanbul ignore file */ | ||
getStructuredTypeSchema, | ||
StructuredTypeSchema | ||
IStructuredTypeSchema | ||
} from "node-opcua-factory"; | ||
@@ -114,3 +114,3 @@ | ||
function write_enumeration_setter(write: WriteFunc, schema: StructuredTypeSchema, field: FieldType, member: string): void { | ||
function write_enumeration_setter(write: WriteFunc, schema: IStructuredTypeSchema, field: FieldType, member: string): void { | ||
const capMember = capitalizeFirstLetter(member); | ||
@@ -130,3 +130,3 @@ write(` public set${capMember}(value: any): ${field.fieldType} {`); | ||
write: WriteFunc, | ||
schema: StructuredTypeSchema, | ||
schema: IStructuredTypeSchema, | ||
field: FieldType, | ||
@@ -139,3 +139,3 @@ member: string, | ||
function write_enumeration(write: WriteFunc, schema: StructuredTypeSchema, field: FieldType, member: string, i: number): void { | ||
function write_enumeration(write: WriteFunc, schema: IStructuredTypeSchema, field: FieldType, member: string, i: number): void { | ||
assert(!field.isArray); // would not work in this case | ||
@@ -146,3 +146,3 @@ const capMember = capitalizeFirstLetter(member); | ||
function write_complex_fast_init(write: WriteFunc, schema: StructuredTypeSchema, field: FieldType, member: string) { | ||
function write_complex_fast_init(write: WriteFunc, schema: IStructuredTypeSchema, field: FieldType, member: string) { | ||
if (field.isArray) { | ||
@@ -155,3 +155,3 @@ write(` this.${member} = null; /* null array */`); | ||
function write_complex(write: WriteFunc, schema: StructuredTypeSchema, field: FieldType, member: string /*, i*/) { | ||
function write_complex(write: WriteFunc, schema: IStructuredTypeSchema, field: FieldType, member: string /*, i*/) { | ||
if (field.isArray) { | ||
@@ -180,3 +180,3 @@ if (Object.prototype.hasOwnProperty.call(field, "defaultValue")) { | ||
function write_basic(write: WriteFunc, schema: StructuredTypeSchema, field: FieldType, member: string, i: number): void { | ||
function write_basic(write: WriteFunc, schema: IStructuredTypeSchema, field: FieldType, member: string, i: number): void { | ||
assert(field.category === FieldCategory.basic); | ||
@@ -195,3 +195,3 @@ | ||
} | ||
function write_basic_fast_init(write: WriteFunc, schema: StructuredTypeSchema, field: FieldType, member: string, i: number): void { | ||
function write_basic_fast_init(write: WriteFunc, schema: IStructuredTypeSchema, field: FieldType, member: string, i: number): void { | ||
if (field.isArray) { | ||
@@ -213,2 +213,3 @@ // write(`this.${member} = [];`); | ||
break; | ||
case "String": | ||
case "UAString": | ||
@@ -263,3 +264,3 @@ write(` this.${member} = null;`); | ||
} | ||
function write_fast_init_member(write: WriteFunc, schema: StructuredTypeSchema, field: FieldType, i: number) { | ||
function write_fast_init_member(write: WriteFunc, schema: IStructuredTypeSchema, field: FieldType, i: number) { | ||
const member = field.name; | ||
@@ -279,3 +280,3 @@ switch (field.category) { | ||
function write_constructor(write: WriteFunc, schema: StructuredTypeSchema): void { | ||
function write_constructor(write: WriteFunc, schema: IStructuredTypeSchema): void { | ||
const baseClass = schema.baseType; | ||
@@ -394,3 +395,3 @@ const className = schema.name; | ||
function write_isValid(write: WriteFunc, schema: StructuredTypeSchema): void { | ||
function write_isValid(write: WriteFunc, schema: IStructuredTypeSchema): void { | ||
// --------------------------------------- | ||
@@ -410,3 +411,3 @@ if (typeof schema.isValid === "function") { | ||
function write_encode(write: WriteFunc, schema: StructuredTypeSchema): void { | ||
function write_encode(write: WriteFunc, schema: IStructuredTypeSchema): void { | ||
if (typeof schema.encode === "function") { | ||
@@ -455,3 +456,3 @@ write(" public encode(stream: OutputBinaryStream): void {"); | ||
function write_decode(write: WriteFunc, schema: StructuredTypeSchema): void { | ||
function write_decode(write: WriteFunc, schema: IStructuredTypeSchema): void { | ||
// -------------------------------------------------------------- | ||
@@ -533,3 +534,3 @@ // implement decode | ||
function hasEnumeration(schema: StructuredTypeSchema): boolean { | ||
function hasEnumeration(schema: IStructuredTypeSchema): boolean { | ||
for (const field of schema.fields) { | ||
@@ -543,3 +544,3 @@ if (field.category === FieldCategory.enumeration) { | ||
function hasComplex(schema: StructuredTypeSchema): boolean { | ||
function hasComplex(schema: IStructuredTypeSchema): boolean { | ||
for (const field of schema.fields) { | ||
@@ -553,3 +554,3 @@ if (field.category === FieldCategory.complex) { | ||
function write_class_constructor_options(write: WriteFunc, schema: StructuredTypeSchema): void { | ||
function write_class_constructor_options(write: WriteFunc, schema: IStructuredTypeSchema): void { | ||
const n = schema.fields.length; | ||
@@ -564,3 +565,3 @@ for (let i = 0; i < n; i++) { | ||
case FieldCategory.enumeration: { | ||
write(` ${member}?: ${field.fieldType}${arrayOpt};`); | ||
write(` ${member}?: ${toJavascriptType(field.fieldType)}${arrayOpt};`); | ||
break; | ||
@@ -570,5 +571,5 @@ } | ||
if (field.fieldType === "ExtensionObject") { | ||
write(` ${member}?: (${field.fieldType} | null)${arrayOpt};`); | ||
write(` ${member}?: (${toJavascriptType(field.fieldType)} | null)${arrayOpt};`); | ||
} else if (field.fieldType === "DiagnosticInfo") { | ||
write(` ${member}?: (${field.fieldType} | null)${arrayOpt};`); | ||
write(` ${member}?: (${toJavascriptType(field.fieldType)} | null)${arrayOpt};`); | ||
} else if ( | ||
@@ -581,5 +582,5 @@ field.fieldType === "Variant" || | ||
) { | ||
write(` ${member}?: (${field.fieldType}Like | null)${arrayOpt};`); | ||
write(` ${member}?: (${toJavascriptType(field.fieldType)}Like | null)${arrayOpt};`); | ||
} else { | ||
write(` ${member}?: ${field.fieldType} ${arrayOpt};`); | ||
write(` ${member}?: ${toJavascriptType(field.fieldType)} ${arrayOpt};`); | ||
} | ||
@@ -595,4 +596,13 @@ break; | ||
} | ||
function write_declare_class_member(write: WriteFunc, schema: StructuredTypeSchema): void { | ||
function toJavascriptType(fieldType: string) { | ||
switch (fieldType) { | ||
case "String": | ||
return "UAString"; | ||
case "Boolean": | ||
return "UABoolean"; | ||
default: | ||
return fieldType; | ||
} | ||
} | ||
function write_declare_class_member(write: WriteFunc, schema: IStructuredTypeSchema): void { | ||
const n = schema.fields.length; | ||
@@ -607,3 +617,3 @@ for (let i = 0; i < n; i++) { | ||
case FieldCategory.enumeration: { | ||
write(` public ${member}: ${field.fieldType}${arrayOpt};`); | ||
write(` public ${member}: ${toJavascriptType(field.fieldType)}${arrayOpt};`); | ||
break; | ||
@@ -613,7 +623,7 @@ } | ||
if (field.fieldType === "DiagnosticInfo") { | ||
write(` public ${member}: (${field.fieldType} | null)${arrayOpt};`); | ||
write(` public ${member}: (${toJavascriptType(field.fieldType)} | null)${arrayOpt};`); | ||
} else if (field.fieldType === "ExtensionObject") { | ||
write(` public ${member}: (${field.fieldType} | null)${arrayOpt};`); | ||
write(` public ${member}: (${toJavascriptType(field.fieldType)} | null)${arrayOpt};`); | ||
} else { | ||
write(` public ${member}: ${field.fieldType}${arrayOpt};`); | ||
write(` public ${member}: ${toJavascriptType(field.fieldType)}${arrayOpt};`); | ||
} | ||
@@ -623,3 +633,3 @@ break; | ||
case FieldCategory.complex: { | ||
write(` public ${member}: ${field.fieldType}${arrayOpt};`); | ||
write(` public ${member}: ${toJavascriptType(field.fieldType)}${arrayOpt};`); | ||
break; | ||
@@ -631,3 +641,3 @@ } | ||
function write_enumerations(write: WriteFunc, schema: StructuredTypeSchema): void { | ||
function write_enumerations(write: WriteFunc, schema: IStructuredTypeSchema): void { | ||
if (!hasEnumeration(schema)) { | ||
@@ -651,3 +661,3 @@ return; | ||
function write_expose_encoder_decoder(write: WriteFunc, schema: StructuredTypeSchema): void { | ||
function write_expose_encoder_decoder(write: WriteFunc, schema: IStructuredTypeSchema): void { | ||
write(""); | ||
@@ -688,3 +698,3 @@ write('import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";'); | ||
field.fieldType + | ||
': (value: any, stream: OutputBinaryStream) => void = getBuildInType("' + | ||
': (value: any, stream: OutputBinaryStream) => void = getBuiltInType("' + | ||
field.fieldType + | ||
@@ -696,3 +706,3 @@ '").encode;' | ||
field.fieldType + | ||
': (stream: BinaryStream) => void = getBuildInType("' + | ||
': (stream: BinaryStream) => void = getBuiltInType("' + | ||
field.fieldType + | ||
@@ -707,3 +717,3 @@ '").decode;' | ||
export function writeStructuredType(write: WriteFunc, schema: StructuredTypeSchema): void { | ||
export function writeStructuredType(write: WriteFunc, schema: IStructuredTypeSchema): void { | ||
const className = schema.name; | ||
@@ -793,3 +803,3 @@ const baseClass = schema.baseType; | ||
function getDataTypeNodeId(schema: StructuredTypeSchema): NodeId { | ||
function getDataTypeNodeId(schema: IStructuredTypeSchema): NodeId { | ||
const className = schema.name; | ||
@@ -799,3 +809,3 @@ const encodingBinaryId = (DataTypeIds as any)[className]; | ||
} | ||
function getEncodingBinaryId(schema: StructuredTypeSchema): NodeId { | ||
function getEncodingBinaryId(schema: IStructuredTypeSchema): NodeId { | ||
const className = schema.name; | ||
@@ -806,3 +816,3 @@ const encodingBinaryId = (ObjectIds as any)[className + "_Encoding_DefaultBinary"]; | ||
function getEncodingXmlId(schema: StructuredTypeSchema): NodeId { | ||
function getEncodingXmlId(schema: IStructuredTypeSchema): NodeId { | ||
const className = schema.name; | ||
@@ -812,3 +822,3 @@ const encodingXmlId = (ObjectIds as any)[className + "_Encoding_DefaultXml"]; | ||
} | ||
function getEncodingJsonId(schema: StructuredTypeSchema): NodeId { | ||
function getEncodingJsonId(schema: IStructuredTypeSchema): NodeId { | ||
const className = schema.name; | ||
@@ -821,3 +831,3 @@ const encodingXmlId = (ObjectIds as any)[className + "_Encoding_DefaultJson"]; | ||
export function produce_TScript_code( | ||
schema: StructuredTypeSchema, | ||
schema: IStructuredTypeSchema, | ||
localSchemaFile: string, | ||
@@ -863,3 +873,3 @@ generatedTypescriptFilename: string | ||
write(` generate_new_id,`); | ||
write(` getBuildInType,`); | ||
write(` getBuiltInType,`); | ||
write(` registerClassDefinition,`); | ||
@@ -866,0 +876,0 @@ write(` getStructuredTypeSchema,`); |
@@ -24,3 +24,4 @@ /* eslint-disable max-statements */ | ||
StructuredTypeSchema, | ||
DataTypeFactory | ||
DataTypeFactory, | ||
IStructuredTypeSchema | ||
} from "node-opcua-factory"; | ||
@@ -117,3 +118,3 @@ import { NodeId } from "node-opcua-nodeid"; | ||
function writeStructuredTypeWithSchema(structuredType: StructuredTypeSchema) { | ||
function writeStructuredTypeWithSchema(structuredType: IStructuredTypeSchema) { | ||
write(`// --------------------------------------------------------------------------------------------`); | ||
@@ -306,3 +307,3 @@ | ||
function processStructuredType(structuredType: StructuredTypeSchema): void { | ||
function processStructuredType(structuredType: IStructuredTypeSchema): void { | ||
if (alreadyDone[structuredType.name]) { | ||
@@ -330,3 +331,3 @@ return; | ||
processStructuredType(dataTypeFactory.getStructuredTypeSchema("LocalizedText")); | ||
//xx processStructuredType(dataTypeFactory.getStructuredTypeSchema("LocalizedText")); | ||
processStructuredType(dataTypeFactory.getStructuredTypeSchema("AxisInformation")); | ||
@@ -333,0 +334,0 @@ // processStructuredType(dataTypeFactory.getStructuredTypeSchema("DiagnosticInfo")); |
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
170780
2832
+ Addednode-opcua-basic-types@2.73.0(transitive)
+ Addednode-opcua-binary-stream@2.73.0(transitive)
+ Addednode-opcua-data-model@2.73.0(transitive)
+ Addednode-opcua-data-value@2.73.0(transitive)
+ Addednode-opcua-date-time@2.73.0(transitive)
+ Addednode-opcua-extension-object@2.73.0(transitive)
+ Addednode-opcua-factory@2.73.0(transitive)
+ Addednode-opcua-numeric-range@2.73.0(transitive)
+ Addednode-opcua-schemas@2.73.0(transitive)
+ Addednode-opcua-status-code@2.73.0(transitive)
+ Addednode-opcua-variant@2.73.0(transitive)
+ Addednode-opcua-xml2json@2.73.0(transitive)
- Removednode-opcua-basic-types@2.72.1(transitive)
- Removednode-opcua-binary-stream@2.71.0(transitive)
- Removednode-opcua-data-model@2.72.1(transitive)
- Removednode-opcua-data-value@2.72.2(transitive)
- Removednode-opcua-date-time@2.71.0(transitive)
- Removednode-opcua-extension-object@2.72.1(transitive)
- Removednode-opcua-factory@2.72.1(transitive)
- Removednode-opcua-numeric-range@2.72.2(transitive)
- Removednode-opcua-schemas@2.72.2(transitive)
- Removednode-opcua-status-code@2.71.0(transitive)
- Removednode-opcua-variant@2.72.2(transitive)
- Removednode-opcua-xml2json@2.71.0(transitive)
Updatednode-opcua-data-model@2.73.0
Updatednode-opcua-data-value@2.73.0
Updatednode-opcua-date-time@2.73.0
Updatednode-opcua-factory@2.73.0
Updatednode-opcua-schemas@2.73.0
Updatednode-opcua-variant@2.73.0
Updatednode-opcua-xml2json@2.73.0