node-opcua-schemas 2.55.0 → 2.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,6 @@ export function getOrCreateConstructor(
28
28
  encodingDefaultBinary?: ExpandedNodeId,
29
29
  encodingDefaultXml?: ExpandedNodeId
30
30
  ): AnyConstructorFunc {
31
-
32
31
  if (dataTypeFactory.hasStructuredType(dataTypeName)) {
33
32
  return dataTypeFactory.getStructureTypeConstructor(dataTypeName);
34
33
  }
@@ -70,7 +69,7 @@ function encodeArrayOrElement(
70
69
  if (field.isArray) {
71
70
  const array = obj[field.name];
72
71
  if (!array) {
73
- stream.writeUInt32(0xFFFFFFFF);
72
+ stream.writeUInt32(0xffffffff);
74
73
  } else {
75
74
  stream.writeUInt32(array.length);
76
75
  for (const e of array) {
@@ -88,8 +87,9 @@ function encodeArrayOrElement(
88
87
  if (!obj[field.name].encode) {
89
88
  // tslint:disable:no-console
90
89
  console.log(obj.schema.fields, field);
91
- throw new Error("encodeArrayOrElement: object field "
92
- + field.name + " has no encode method and encodeFunc is missing");
90
+ throw new Error(
91
+ "encodeArrayOrElement: object field " + field.name + " has no encode method and encodeFunc is missing"
92
+ );
93
93
  }
94
94
  obj[field.name].encode(stream);
95
95
  }
@@ -106,14 +106,13 @@ function decodeArrayOrElement(
106
106
  if (field.isArray) {
107
107
  const array = [];
108
108
  const nbElements = stream.readUInt32();
109
- if (nbElements === 0xFFFFFFFF) {
109
+ if (nbElements === 0xffffffff) {
110
110
  obj[field.name] = null;
111
111
  } else {
112
112
  for (let i = 0; i < nbElements; i++) {
113
113
  if (decodeFunc) {
114
114
  array.push(decodeFunc(stream));
115
115
  } else {
116
-
117
116
  // construct an instance
118
117
  const constructor = factory.getStructureTypeConstructor(field.fieldType);
119
118
  const element = new constructor({});
@@ -136,14 +135,7 @@ function decodeArrayOrElement(
136
135
  }
137
136
  }
138
137
 
139
- function initializeField(
140
- field: FieldType,
141
- thisAny: any,
142
- options: any,
143
- schema: StructuredTypeSchema,
144
- factory: DataTypeFactory
145
- ) {
146
-
138
+ function initializeField(field: FieldType, thisAny: any, options: any, schema: StructuredTypeSchema, factory: DataTypeFactory) {
147
139
  const name = field.name;
148
140
 
149
141
  switch (field.category) {
@@ -155,11 +147,9 @@ function initializeField(
155
147
  if (!arr.map) {
156
148
  console.log("Error", options);
157
149
  }
158
- (thisAny)[name] = arr.map((x: any) =>
159
- constructor ? new constructor(x) : null
160
- );
150
+ thisAny[name] = arr.map((x: any) => (constructor ? new constructor(x) : null));
161
151
  } else {
162
- (thisAny)[name] = constructor ? new constructor(options[name]) : null;
152
+ thisAny[name] = constructor ? new constructor(options[name]) : null;
163
153
  }
164
154
  // xx processStructuredType(fieldSchema);
165
155
  break;
@@ -167,9 +157,9 @@ function initializeField(
167
157
  case FieldCategory.enumeration:
168
158
  case FieldCategory.basic:
169
159
  if (field.isArray) {
170
- (thisAny)[name] = initialize_field_array(field, options[name]);
160
+ thisAny[name] = initialize_field_array(field, options[name]);
171
161
  } else {
172
- (thisAny)[name] = initialize_field(field, options[name]);
162
+ thisAny[name] = initialize_field(field, options[name]);
173
163
  }
174
164
  break;
175
165
  }
@@ -182,19 +172,17 @@ function initializeField(
182
172
  * @param factory
183
173
  */
184
174
  function initializeFields(thisAny: any, options: any, schema: StructuredTypeSchema, factory: DataTypeFactory) {
185
-
186
175
  // initialize base class first
187
176
  if (schema._baseSchema && schema._baseSchema.fields.length) {
188
177
  initializeFields(thisAny, options, schema._baseSchema!, factory);
189
178
  }
190
179
  // finding fields that are in options but not in schema!
191
180
  for (const field of schema.fields) {
192
-
193
181
  const name = field.name;
194
182
 
195
183
  // dealing with optional fields
196
184
  if (field.switchBit !== undefined && options[field.name] === undefined) {
197
- (thisAny)[name] = undefined;
185
+ thisAny[name] = undefined;
198
186
  continue;
199
187
  }
200
188
  initializeField(field, thisAny, options, schema, factory);
@@ -205,7 +193,7 @@ function hasOptionalFieldsF(schema: StructuredTypeSchema): boolean {
205
193
  if (schema.bitFields && schema.bitFields.length > 0) {
206
194
  return true;
207
195
  }
208
- return (schema._baseSchema ? hasOptionalFieldsF(schema._baseSchema) : false);
196
+ return schema._baseSchema ? hasOptionalFieldsF(schema._baseSchema) : false;
209
197
  }
210
198
 
211
199
  function _internal_encodeFields(thisAny: any, schema: StructuredTypeSchema, stream: OutputBinaryStream) {
@@ -214,9 +202,8 @@ function _internal_encodeFields(thisAny: any, schema: StructuredTypeSchema, stre
214
202
  _internal_encodeFields(thisAny, schema._baseSchema!, stream);
215
203
  }
216
204
  for (const field of schema.fields) {
217
-
218
205
  // ignore
219
- if (field.switchBit !== undefined && (thisAny)[field.name] === undefined) {
206
+ if (field.switchBit !== undefined && thisAny[field.name] === undefined) {
220
207
  continue;
221
208
  }
222
209
 
@@ -240,9 +227,10 @@ interface BitfieldOffset {
240
227
  allOptional: boolean;
241
228
  }
242
229
  function makeBitField(thisAny: any, schema: StructuredTypeSchema, bo: BitfieldOffset): BitfieldOffset {
230
+ const data = schema._baseSchema ? makeBitField(thisAny, schema._baseSchema, bo) : bo;
231
+ let { bitField, allOptional } = data;
232
+ const { offset } = data;
243
233
 
244
- // tslint:disable-next-line: prefer-const
245
- let { bitField, offset, allOptional } = schema._baseSchema ? makeBitField(thisAny, schema._baseSchema, bo) : bo;
246
234
  let nbOptionalFields = 0;
247
235
  for (const field of schema.fields) {
248
236
  if (field.switchBit === undefined) {
@@ -250,17 +238,15 @@ function makeBitField(thisAny: any, schema: StructuredTypeSchema, bo: BitfieldOf
250
238
  continue;
251
239
  }
252
240
  nbOptionalFields += 1;
253
- if ((thisAny)[field.name] === undefined) {
241
+ if (thisAny[field.name] === undefined) {
254
242
  continue;
255
243
  }
256
244
  // tslint:disable-next-line:no-bitwise
257
- bitField |= (1 << (field.switchBit + offset));
258
-
245
+ bitField |= 1 << (field.switchBit + offset);
259
246
  }
260
247
  return { bitField, offset: nbOptionalFields + offset, allOptional };
261
248
  }
262
249
  function encodeFields(thisAny: any, schema: StructuredTypeSchema, stream: OutputBinaryStream) {
263
-
264
250
  const hasOptionalFields = hasOptionalFieldsF(schema);
265
251
  // ============ Deal with switchBits
266
252
  if (hasOptionalFields) {
@@ -286,15 +272,14 @@ function internal_decodeFields(
286
272
  internal_decodeFields(thisAny, bitField, hasOptionalFields, schema._baseSchema, stream, factory);
287
273
  }
288
274
  for (const field of schema.fields) {
289
-
290
275
  // ignore fields that have a switch bit when bit is not set
291
276
  if (hasOptionalFields && field.switchBit !== undefined) {
292
277
  // tslint:disable-next-line:no-bitwise
293
278
  if ((bitField & (1 << field.switchBit)) === 0) {
294
- (thisAny)[field.name] = undefined;
279
+ thisAny[field.name] = undefined;
295
280
  continue;
296
281
  } else {
297
- if (field.category === FieldCategory.complex && (thisAny)[field.name] === undefined) {
282
+ if (field.category === FieldCategory.complex && thisAny[field.name] === undefined) {
298
283
  // need to create empty structure for deserialisation
299
284
  initializeField(field, thisAny, {}, schema, factory);
300
285
  }
@@ -314,20 +299,13 @@ function internal_decodeFields(
314
299
  throw new Error("Invalid category " + field.category + " " + FieldCategory[field.category]);
315
300
  }
316
301
  }
317
-
318
302
  }
319
303
 
320
- function decodeFields(
321
- thisAny: any,
322
- schema: StructuredTypeSchema,
323
- stream: BinaryStream,
324
- factory: DataTypeFactory
325
- ) {
326
-
304
+ function decodeFields(thisAny: any, schema: StructuredTypeSchema, stream: BinaryStream, factory: DataTypeFactory) {
327
305
  // ============ Deal with switchBits
328
306
  const hasOptionalFields = hasOptionalFieldsF(schema);
329
307
  let bitField = 0;
330
- if (hasOptionalFields && (stream.buffer.length - stream.length) > 0) {
308
+ if (hasOptionalFields && stream.buffer.length - stream.length > 0) {
331
309
  bitField = stream.readUInt32();
332
310
  }
333
311
 
@@ -340,7 +318,7 @@ function ___fieldToJson(field: FieldType, value: any): any {
340
318
  return value ? value?.toJSON() : null;
341
319
  case FieldCategory.enumeration:
342
320
  case FieldCategory.basic:
343
- return value instanceof Date ? new Date(value.getTime()) : (value?.toJSON ? value?.toJSON() : value);
321
+ return value instanceof Date ? new Date(value.getTime()) : value?.toJSON ? value?.toJSON() : value;
344
322
  default:
345
323
  /* istanbul ignore next*/
346
324
  throw new Error("Invalid category " + field.category + " " + FieldCategory[field.category]);
@@ -355,11 +333,7 @@ function fieldToJSON(field: FieldType, value: any): any {
355
333
  return ___fieldToJson(field, value);
356
334
  }
357
335
  }
358
- function encodeToJson(
359
- thisAny: any,
360
- schema: StructuredTypeSchema,
361
- pojo: any) {
362
-
336
+ function encodeToJson(thisAny: any, schema: StructuredTypeSchema, pojo: any) {
363
337
  if (schema._baseSchema && schema._baseSchema.fields.length) {
364
338
  encodeToJson(thisAny, schema._baseSchema!, pojo);
365
339
  }
@@ -379,7 +353,6 @@ interface T {
379
353
  const _private = new WeakMap<T>();
380
354
 
381
355
  export class DynamicExtensionObject extends ExtensionObject {
382
-
383
356
  public static schema: StructuredTypeSchema = ExtensionObject.schema;
384
357
  public static possibleFields: string[] = [];
385
358
 
@@ -421,21 +394,20 @@ export class DynamicExtensionObject extends ExtensionObject {
421
394
  encodeToJson(this, this.schema, pojo);
422
395
  return pojo;
423
396
  }
424
-
425
397
  }
426
398
 
427
399
  // tslint:disable:callable-types
428
400
  interface AnyConstructable {
429
401
  schema: StructuredTypeSchema;
430
402
  possibleFields: string[];
431
- new(options?: any, schema?: StructuredTypeSchema, factory?: DataTypeFactory): any;
403
+ new (options?: any, schema?: StructuredTypeSchema, factory?: DataTypeFactory): any;
432
404
  }
433
405
 
434
406
  export type AnyConstructorFunc = AnyConstructable;
435
407
 
436
408
  // tslint:disable-next-line:max-classes-per-file
437
409
  class UnionBaseClass extends BaseUAObject {
438
-
410
+ // eslint-disable-next-line max-statements
439
411
  constructor(options: any, schema: StructuredTypeSchema, factory: DataTypeFactory) {
440
412
  super();
441
413
 
@@ -451,7 +423,6 @@ class UnionBaseClass extends BaseUAObject {
451
423
  let switchFieldName = "";
452
424
  // finding fields that are in options but not in schema!
453
425
  for (const field of this.schema.fields) {
454
-
455
426
  const name = field.name;
456
427
  if (field.switchValue === undefined) {
457
428
  // this is the switch value field
@@ -467,9 +438,14 @@ class UnionBaseClass extends BaseUAObject {
467
438
  if (uniqueFieldHasBeenFound && options[field.name] !== undefined) {
468
439
  // let try to be helpful for the developper by providing some hint
469
440
  debugLog(this.schema);
470
- throw new Error("union must have only one choice in " + JSON.stringify(options) +
471
- "\n found while investigating " + field.name +
472
- "\n switchFieldName = " + switchFieldName);
441
+ throw new Error(
442
+ "union must have only one choice in " +
443
+ JSON.stringify(options) +
444
+ "\n found while investigating " +
445
+ field.name +
446
+ "\n switchFieldName = " +
447
+ switchFieldName
448
+ );
473
449
  }
474
450
 
475
451
  if (options[switchFieldName] !== undefined) {
@@ -491,9 +467,7 @@ class UnionBaseClass extends BaseUAObject {
491
467
  const constuctor = factory.getStructureTypeConstructor(field.fieldType);
492
468
  // getOrCreateConstructor(field.fieldType, factory) || BaseUAObject;
493
469
  if (field.isArray) {
494
- (this as any)[name] = (options[name] || []).map((x: any) =>
495
- constuctor ? new constuctor(x) : null
496
- );
470
+ (this as any)[name] = (options[name] || []).map((x: any) => (constuctor ? new constuctor(x) : null));
497
471
  } else {
498
472
  (this as any)[name] = constuctor ? new constuctor(options[name]) : null;
499
473
  }
@@ -508,7 +482,6 @@ class UnionBaseClass extends BaseUAObject {
508
482
  (this as any)[name] = initialize_field(field, options[name]);
509
483
  }
510
484
  break;
511
-
512
485
  }
513
486
  }
514
487
  if (!uniqueFieldHasBeenFound) {
@@ -516,22 +489,27 @@ class UnionBaseClass extends BaseUAObject {
516
489
  (this as any)[switchFieldName] = 0x00;
517
490
  return;
518
491
  }
519
- const r = schema.fields.filter((f) => f.switchValue !== undefined).map((f) => f.name).join(" , ");
492
+ const r = schema.fields
493
+ .filter((f) => f.switchValue !== undefined)
494
+ .map((f) => f.name)
495
+ .join(" , ");
520
496
  // it is possible also that the switchfield value do not correspond to a valid field
521
- const foundFieldForSwitchValue = schema.fields.findIndex((f) =>
522
- f.switchValue !== undefined && f.switchValue === options[switchFieldName]);
497
+ const foundFieldForSwitchValue = schema.fields.findIndex(
498
+ (f) => f.switchValue !== undefined && f.switchValue === options[switchFieldName]
499
+ );
523
500
  if (foundFieldForSwitchValue) {
524
501
  // throw new Error(this.schema.name + ": cannot find field with value "
525
502
  // + options[switchFieldName]);
526
503
  } else {
527
504
  console.log(this.schema);
528
- throw new Error(this.schema.name + ": At least one of [ " + r + " ] must be specified in " + JSON.stringify(options));
505
+ throw new Error(
506
+ this.schema.name + ": At least one of [ " + r + " ] must be specified in " + JSON.stringify(options)
507
+ );
529
508
  }
530
509
  }
531
510
  }
532
511
 
533
512
  public encode(stream: OutputBinaryStream): void {
534
-
535
513
  const switchFieldName = this.schema.fields[0].name;
536
514
  const switchValue = (this as any)[switchFieldName];
537
515
  if (typeof switchValue !== "number") {
@@ -568,7 +546,6 @@ class UnionBaseClass extends BaseUAObject {
568
546
  (this as any)[switchFieldName] = switchValue;
569
547
 
570
548
  for (const field of this.schema.fields) {
571
-
572
549
  if (field.switchValue === undefined || field.switchValue !== switchValue) {
573
550
  continue;
574
551
  }
@@ -598,7 +575,6 @@ class UnionBaseClass extends BaseUAObject {
598
575
  }
599
576
 
600
577
  public toJSON(): any {
601
-
602
578
  const pojo: any = {};
603
579
  const switchFieldName = this.schema.fields[0].name;
604
580
  const switchValue = (this as any)[switchFieldName];
@@ -621,14 +597,9 @@ class UnionBaseClass extends BaseUAObject {
621
597
  }
622
598
  return pojo;
623
599
  }
624
-
625
600
  }
626
601
 
627
- function _createDynamicUnionConstructor(
628
- schema: StructuredTypeSchema,
629
- factory: DataTypeFactory
630
- ): AnyConstructorFunc {
631
-
602
+ function _createDynamicUnionConstructor(schema: StructuredTypeSchema, factory: DataTypeFactory): AnyConstructorFunc {
632
603
  const possibleFields = schema.fields.map((x: FieldType) => x.name);
633
604
 
634
605
  // tslint:disable-next-line:max-classes-per-file
@@ -640,21 +611,15 @@ function _createDynamicUnionConstructor(
640
611
  super(options, schema, factory);
641
612
  assert(this.schema === schema);
642
613
  }
643
-
644
614
  }
645
615
 
646
616
  // to do : may be remove DataType suffix here ?
647
617
  Object.defineProperty(UNION, "name", { value: schema.name });
648
618
 
649
619
  return UNION;
650
-
651
620
  }
652
621
 
653
- export function createDynamicObjectConstructor(
654
- schema: StructuredTypeSchema,
655
- dataTypeFactory: DataTypeFactory
656
- ): AnyConstructorFunc {
657
-
622
+ export function createDynamicObjectConstructor(schema: StructuredTypeSchema, dataTypeFactory: DataTypeFactory): AnyConstructorFunc {
658
623
  const schemaPriv = schema as any;
659
624
 
660
625
  if (schemaPriv.$Constructor) {
@@ -673,13 +638,13 @@ export function createDynamicObjectConstructor(
673
638
 
674
639
  let BaseClass: AnyConstructorFunc = DynamicExtensionObject as AnyConstructorFunc;
675
640
 
676
- if (schema.baseType !== "ExtensionObject"
677
- && schema.baseType !== "OptionSet"
678
- && schema.baseType !== "DataTypeDescription"
679
- && schema.baseType !== "DataTypeDefinition"
680
- && schema.baseType !== "EnumValueType"
641
+ if (
642
+ schema.baseType !== "ExtensionObject" &&
643
+ schema.baseType !== "OptionSet" &&
644
+ schema.baseType !== "DataTypeDescription" &&
645
+ schema.baseType !== "DataTypeDefinition" &&
646
+ schema.baseType !== "EnumValueType"
681
647
  ) {
682
-
683
648
  try {
684
649
  const baseSchema = dataTypeFactory.getStructuredTypeSchema(schema.baseType);
685
650
  schema._baseSchema = baseSchema;
@@ -695,7 +660,6 @@ export function createDynamicObjectConstructor(
695
660
  }
696
661
  schema._baseSchema = BaseClass.schema;
697
662
  }
698
-
699
663
  } catch (err) {
700
664
  // xx console.log("createDynamicObjectConstructor err= ", err.message);
701
665
  }
@@ -706,8 +670,10 @@ export function createDynamicObjectConstructor(
706
670
  public static encodingDefaultXml = new ExpandedNodeId(NodeIdType.NUMERIC, 0, 0);
707
671
  public static encodingDefaultBinary = new ExpandedNodeId(NodeIdType.NUMERIC, 0, 0);
708
672
  public static possibleFields = possibleFields;
709
- public static get schema(): StructuredTypeSchema { return schema; }
710
-
673
+ public static get schema(): StructuredTypeSchema {
674
+ return schema;
675
+ }
676
+
711
677
  constructor(options?: any, schema2?: StructuredTypeSchema, factory2?: DataTypeFactory) {
712
678
  super(options, schema2 ? schema2 : schema, factory2 ? factory2 : dataTypeFactory);
713
679
  }
package/source/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./parse_binary_xsd";
2
- export * from "./dynamic_extension_object";
3
- export * from "./toTypeScript";
4
- export * from "./tools";
1
+ export * from "./parse_binary_xsd";
2
+ export * from "./dynamic_extension_object";
3
+ export * from "./toTypeScript";
4
+ export * from "./tools";
@@ -7,10 +7,7 @@
7
7
  import * as chalk from "chalk";
8
8
 
9
9
  import assert from "node-opcua-assert";
10
- import {
11
- checkDebugFlag,
12
- make_debugLog
13
- } from "node-opcua-debug";
10
+ import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
14
11
  import {
15
12
  EnumerationDefinitionSchema,
16
13
  FieldInterfaceOptions,
@@ -21,11 +18,8 @@ import {
21
18
  import { DataTypeFactory } from "node-opcua-factory";
22
19
  import { NodeId } from "node-opcua-nodeid";
23
20
  import { Xml2Json } from "node-opcua-xml2json";
24
- import { Z_UNKNOWN } from "zlib";
25
21
 
26
- import {
27
- getOrCreateStructuredTypeSchema,
28
- } from "./tools";
22
+ import { getOrCreateStructuredTypeSchema } from "./tools";
29
23
 
30
24
  const doDebug = checkDebugFlag(__filename);
31
25
  const debugLog = make_debugLog(__filename);
@@ -76,7 +70,6 @@ const predefinedType: any = {
76
70
  const found: any = {};
77
71
 
78
72
  function resolveType(typeDictionary: string, typeName: string) {
79
-
80
73
  const namespace = typeName.split(":")[0];
81
74
  if (predefinedType[typeName]) {
82
75
  return;
@@ -85,6 +78,7 @@ function resolveType(typeDictionary: string, typeName: string) {
85
78
  found[typeName] = typeName;
86
79
  }
87
80
  if (namespace === "ua") {
81
+ /** */
88
82
  }
89
83
  }
90
84
 
@@ -110,14 +104,15 @@ export interface ITypeDictionary {
110
104
  }
111
105
 
112
106
  export class TypeDictionary implements ITypeDictionary {
113
- public targetNamespace: string = "";
107
+ public targetNamespace = "";
114
108
  public imports: string[] = [];
115
109
  public structuredTypesRaw: StructureTypeRaw[] = [];
116
110
  public enumeratedTypesRaw: EnumeratedType[] = [];
117
111
  private structuredTypesRawMap: any = {};
118
112
  constructor() {
113
+ /** */
119
114
  }
120
- public addRaw(structuredType: StructureTypeRaw) {
115
+ public addRaw(structuredType: StructureTypeRaw): void {
121
116
  this.structuredTypesRaw.push(structuredType);
122
117
  this.structuredTypesRawMap[structuredType.name] = structuredType;
123
118
  }
@@ -134,11 +129,9 @@ const state0: any = {
134
129
  parser: {
135
130
  TypeDictionary: {
136
131
  init: function (this: any, name: string, attributes: any) {
137
-
138
132
  this.typeDictionary = this.engine.typeDictionary as DataTypeFactory;
139
133
  this.typeDictionary.defaultByteOrder = attributes.DefaultByteOrder;
140
134
  this.typeDictionary.targetNamespace = attributes.TargetNamespace;
141
-
142
135
  },
143
136
  parser: {
144
137
  Import: {
@@ -149,20 +142,22 @@ const state0: any = {
149
142
  // _register_namespace_uri(this.text);
150
143
  // istanbul ignore next
151
144
  if (doDebug) {
152
- debugLog("Import NameSpace = ", this.attrs.Namespace,
153
- " Location", this.attrs.Location);
145
+ debugLog("Import NameSpace = ", this.attrs.Namespace, " Location", this.attrs.Location);
154
146
  }
155
147
  }
156
148
  },
157
149
 
158
150
  EnumeratedType: {
159
151
  init: function (this: any) {
160
-
161
152
  this.typescriptDefinition = "";
162
153
  // istanbul ignore next
163
154
  if (doDebug) {
164
- debugLog(chalk.cyan("EnumeratedType Name="),
165
- w(this.attrs.Name, 40), "LengthInBits=", this.attrs.LengthInBits);
155
+ debugLog(
156
+ chalk.cyan("EnumeratedType Name="),
157
+ w(this.attrs.Name, 40),
158
+ "LengthInBits=",
159
+ this.attrs.LengthInBits
160
+ );
166
161
  }
167
162
 
168
163
  this.enumeratedType = {
@@ -183,13 +178,12 @@ const state0: any = {
183
178
  finish: function (this: any) {
184
179
  // istanbul ignore next
185
180
  if (doDebug) {
186
- debugLog(" EnumeratedValue Name=",
187
- w(this.attrs.Name, 40), " Value=", this.attrs.Value);
181
+ debugLog(" EnumeratedValue Name=", w(this.attrs.Name, 40), " Value=", this.attrs.Value);
188
182
  }
189
183
  const key = this.attrs.Name;
190
184
  const value = parseInt(this.attrs.Value, 10);
191
185
  const _enum = this.parent.enumeratedType.enumeratedValues;
192
- _enum[_enum[key] = value] = key;
186
+ _enum[(_enum[key] = value)] = key;
193
187
  this.parent.typescriptDefinition += `\n ${key} = ${value},`;
194
188
  }
195
189
  }
@@ -207,8 +201,12 @@ const state0: any = {
207
201
  init: function (this: any) {
208
202
  // istanbul ignore next
209
203
  if (doDebug) {
210
- debugLog(chalk.cyan("StructureType Name="),
211
- chalk.green(this.attrs.Name), " BaseType=", this.attrs.BaseType);
204
+ debugLog(
205
+ chalk.cyan("StructureType Name="),
206
+ chalk.green(this.attrs.Name),
207
+ " BaseType=",
208
+ this.attrs.BaseType
209
+ );
212
210
  }
213
211
 
214
212
  const baseType = this.attrs.BaseType;
@@ -228,7 +226,6 @@ const state0: any = {
228
226
  parser: {
229
227
  Field: {
230
228
  finish: function (this: any) {
231
-
232
229
  if (this.attrs.SourceType) {
233
230
  // ignore this field, This is a repetition of the base type field with same name
234
231
  return;
@@ -236,11 +233,19 @@ const state0: any = {
236
233
  // istanbul ignore next
237
234
  if (doDebug) {
238
235
  debugLog(
239
- chalk.yellow(" field Name="), w(this.attrs.Name, 40),
240
- chalk.yellow(" typeName="), w(this.attrs.TypeName, 40),
241
- this.attrs.LengthField ? chalk.yellow(" lengthField= ") + w(this.attrs.LengthField, 40) : "",
242
- this.attrs.SwitchField ? chalk.yellow(" SwitchField= ") + w(this.attrs.SwitchField, 40) : "",
243
- this.attrs.SwitchValue !== undefined ? chalk.yellow(" SwitchValue= ") + w(this.attrs.SwitchValue, 40) : "",
236
+ chalk.yellow(" field Name="),
237
+ w(this.attrs.Name, 40),
238
+ chalk.yellow(" typeName="),
239
+ w(this.attrs.TypeName, 40),
240
+ this.attrs.LengthField
241
+ ? chalk.yellow(" lengthField= ") + w(this.attrs.LengthField, 40)
242
+ : "",
243
+ this.attrs.SwitchField
244
+ ? chalk.yellow(" SwitchField= ") + w(this.attrs.SwitchField, 40)
245
+ : "",
246
+ this.attrs.SwitchValue !== undefined
247
+ ? chalk.yellow(" SwitchValue= ") + w(this.attrs.SwitchValue, 40)
248
+ : ""
244
249
  // chalk.yellow(" lengthField="), w(this.attrs.LengthField, 40)
245
250
  );
246
251
  }
@@ -268,7 +273,6 @@ const state0: any = {
268
273
  structuredType.fields.push(field);
269
274
  }
270
275
  if (this.attrs.SwitchField) {
271
-
272
276
  // field is optional and can be omitted
273
277
  const switchField = this.attrs.SwitchField;
274
278
 
@@ -277,7 +281,14 @@ const state0: any = {
277
281
  field.switchValue = parseInt(this.attrs.SwitchValue, 10);
278
282
  // istanbul ignore next
279
283
  if (doDebug) {
280
- debugLog("field", field.name, " is part of a union => ", switchField, " value #", field.switchValue);
284
+ debugLog(
285
+ "field",
286
+ field.name,
287
+ " is part of a union => ",
288
+ switchField,
289
+ " value #",
290
+ field.switchValue
291
+ );
281
292
  }
282
293
  // sometimes (like in Milo, baseType attribute is not specified)
283
294
  if (!this.parent.attrs.baseType) {
@@ -285,11 +296,19 @@ const state0: any = {
285
296
  this.parent.structuredType.baseType = "Union";
286
297
  }
287
298
  } else {
288
- field.switchBit = structuredType.bitFields ?
289
- structuredType.bitFields!.findIndex((x) => x.name === switchField) : -2;
299
+ field.switchBit = structuredType.bitFields
300
+ ? structuredType.bitFields!.findIndex((x) => x.name === switchField)
301
+ : -2;
290
302
  // istanbul ignore next
291
303
  if (doDebug) {
292
- debugLog("field", field.name, " is optional => ", switchField, "bit #", field.switchBit);
304
+ debugLog(
305
+ "field",
306
+ field.name,
307
+ " is optional => ",
308
+ switchField,
309
+ "bit #",
310
+ field.switchBit
311
+ );
293
312
  }
294
313
  }
295
314
  }
@@ -322,17 +341,15 @@ export function parseBinaryXSD(
322
341
  idProvider: MapDataTypeAndEncodingIdProvider,
323
342
  dataTypeFactory: DataTypeFactory,
324
343
  callback: (err?: Error | null) => void
325
- ) {
326
-
344
+ ): void {
327
345
  const parser = new Xml2Json(state0);
328
346
  const typeDictionary = new TypeDictionary();
329
347
  (parser as any).typeDictionary = typeDictionary;
330
348
 
331
349
  parser.parseString(xmlString, (err?: Error | null) => {
332
-
333
350
  // resolve and prepare enumerations
334
351
  for (const key in typeDictionary.enumeratedTypesRaw) {
335
- if (!typeDictionary.enumeratedTypesRaw.hasOwnProperty(key)) {
352
+ if (!Object.prototype.hasOwnProperty.call(typeDictionary.enumeratedTypesRaw, key)) {
336
353
  continue;
337
354
  }
338
355
  const enumeratedType = typeDictionary.enumeratedTypesRaw[key];
@@ -403,7 +420,6 @@ export async function parseBinaryXSDAsync(
403
420
  idProvider: MapDataTypeAndEncodingIdProvider,
404
421
  dataTypeFactory: DataTypeFactory
405
422
  ): Promise<void> {
406
-
407
423
  debugLog("parseBinaryXSDAsync");
408
424
  return new Promise((resolve, reject) => {
409
425
  parseBinaryXSD(xmlString, idProvider, dataTypeFactory, (err?: Error | null) => {