node-opcua-schemas 2.76.2 → 2.78.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.
@@ -4,6 +4,7 @@
4
4
  import { assert } from "node-opcua-assert";
5
5
  import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
6
6
  import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
7
+ import { sameNodeId } from "node-opcua-nodeid";
7
8
  import { decodeExtensionObject, encodeExtensionObject, ExtensionObject } from "node-opcua-extension-object";
8
9
  import { DataType } from "node-opcua-variant";
9
10
 
@@ -17,8 +18,7 @@ import {
17
18
  initialize_field,
18
19
  initialize_field_array,
19
20
  IStructuredTypeSchema,
20
- StructuredTypeField,
21
- StructuredTypeSchema
21
+ StructuredTypeField
22
22
  } from "node-opcua-factory";
23
23
 
24
24
  import { coerceNodeId, ExpandedNodeId, NodeId, NodeIdType } from "node-opcua-nodeid";
@@ -33,8 +33,9 @@ export function getOrCreateConstructor(
33
33
  encodingDefaultBinary?: ExpandedNodeId,
34
34
  encodingDefaultXml?: ExpandedNodeId
35
35
  ): AnyConstructorFunc {
36
- if (dataTypeFactory.hasStructuredType(dataTypeName)) {
37
- return dataTypeFactory.getStructureTypeConstructor(dataTypeName) as unknown as AnyConstructorFunc;
36
+ if (dataTypeFactory.hasStructureByTypeName(dataTypeName)) {
37
+ const structureInfo = dataTypeFactory.getStructureInfoByTypeName(dataTypeName);
38
+ return (structureInfo.constructor || ExtensionObject) as AnyConstructorFunc;
38
39
  }
39
40
  const schema = dataTypeFactory.getStructuredTypeSchema(dataTypeName);
40
41
 
@@ -46,11 +47,11 @@ export function getOrCreateConstructor(
46
47
  const constructor = createDynamicObjectConstructor(schema, dataTypeFactory);
47
48
 
48
49
  if (!constructor) {
49
- return constructor;
50
+ return ExtensionObject as AnyConstructorFunc;
50
51
  }
51
52
  // istanbul ignore next
52
- if (!dataTypeFactory.hasStructuredType(dataTypeName)) {
53
- dataTypeFactory.registerClassDefinition(schema.id, dataTypeName, constructor as ConstructorFuncWithSchema);
53
+ if (!dataTypeFactory.hasStructureByTypeName(dataTypeName)) {
54
+ dataTypeFactory.registerClassDefinition(schema.dataTypeNodeId, dataTypeName, constructor as ConstructorFuncWithSchema);
54
55
  return constructor;
55
56
  // hrow new Error("constructor should now be registered - " + fieldType);
56
57
  }
@@ -109,7 +110,7 @@ function encodeArrayOrElement(
109
110
  }
110
111
 
111
112
  function decodeElement(
112
- factory: DataTypeFactory,
113
+ dataTypeFactory: DataTypeFactory,
113
114
  field: FieldType,
114
115
  stream: BinaryStream,
115
116
  decodeFunc?: (stream: BinaryStream) => any
@@ -122,15 +123,18 @@ function decodeElement(
122
123
  return element;
123
124
  } else {
124
125
  // construct an instance
125
- const constructor = factory.getStructureTypeConstructor(field.fieldType);
126
- const element = new constructor({});
126
+ const structureInfo = dataTypeFactory.getStructureInfoByTypeName(field.fieldType);
127
+ if (!structureInfo.constructor) {
128
+ throw new Error("Cannot instantiate an abstract dataStructure: " + field.fieldType);
129
+ }
130
+ const element = new structureInfo.constructor({});
127
131
  element.decode(stream);
128
132
  return element;
129
133
  }
130
134
  }
131
135
  }
132
136
  function decodeArrayOrElement(
133
- factory: DataTypeFactory,
137
+ dataTypeFactory: DataTypeFactory,
134
138
  field: FieldType,
135
139
  obj: any,
136
140
  stream: BinaryStream,
@@ -143,29 +147,30 @@ function decodeArrayOrElement(
143
147
  obj[field.name] = null;
144
148
  } else {
145
149
  for (let i = 0; i < nbElements; i++) {
146
- const element = decodeElement(factory, field, stream, decodeFunc);
150
+ const element = decodeElement(dataTypeFactory, field, stream, decodeFunc);
147
151
  array.push(element);
148
152
  }
149
153
  obj[field.name] = array;
150
154
  }
151
155
  } else {
152
- obj[field.name] = decodeElement(factory, field, stream, decodeFunc);
156
+ obj[field.name] = decodeElement(dataTypeFactory, field, stream, decodeFunc);
153
157
  }
154
158
  }
155
159
 
156
- function isSubtype(factory: DataTypeFactory, dataTypeNodeId: NodeId, schema: IStructuredTypeSchema): boolean {
157
- if (dataTypeNodeId.toString() === schema.dataTypeNodeId.toString()) {
160
+ function isSubtype(dataTypeFactory: DataTypeFactory, dataTypeNodeId: NodeId, schema: IStructuredTypeSchema): boolean {
161
+ if (sameNodeId(dataTypeNodeId, schema.dataTypeNodeId)) {
158
162
  return true;
159
163
  }
160
- if (!schema._baseSchema || !schema._baseSchema?.dataTypeNodeId) return false;
161
- const c = factory.getConstructorForDataType(schema._baseSchema.dataTypeNodeId);
162
- if (!c) {
164
+ const baseSchema = schema.getBaseSchema();
165
+ if (!baseSchema || !baseSchema?.dataTypeNodeId) return false;
166
+ const structureInfo = dataTypeFactory.getStructureInfoForDataType(baseSchema.dataTypeNodeId);
167
+ if (!structureInfo) {
163
168
  return false;
164
169
  }
165
- return isSubtype(factory, dataTypeNodeId, c.schema);
170
+ return isSubtype(dataTypeFactory, dataTypeNodeId, structureInfo.schema);
166
171
  }
167
172
 
168
- function _validateSubType(factory: DataTypeFactory, field: StructuredTypeField, value: any): void {
173
+ function _validateSubType(dataTypeFactory: DataTypeFactory, field: StructuredTypeField, value: any): void {
169
174
  assert(field.allowSubType);
170
175
  if (!value) {
171
176
  value = { dataType: DataType.Null, value: null };
@@ -180,8 +185,8 @@ function _validateSubType(factory: DataTypeFactory, field: StructuredTypeField,
180
185
  errorLog(msg);
181
186
  throw new Error(msg);
182
187
  }
183
- const c = factory.getBuiltInTypeByDataType(coerceNodeId(`i=${value.dataType}`, 0));
184
- const d = factory.getBuiltInType(field.fieldType);
188
+ const c = dataTypeFactory.getBuiltInTypeByDataType(coerceNodeId(`i=${value.dataType}`, 0));
189
+ const d = dataTypeFactory.getBuiltInType(field.fieldType);
185
190
  if (c && c.isSubTypeOf(d)) {
186
191
  return;
187
192
  }
@@ -201,14 +206,14 @@ function _validateSubType(factory: DataTypeFactory, field: StructuredTypeField,
201
206
  throw new Error(`${field.name}: array element must be an ExtensionObject`);
202
207
  }
203
208
  const e = value as ExtensionObject;
204
- if (!isSubtype(factory, field.dataType!, e.schema)) {
209
+ if (!isSubtype(dataTypeFactory, field.dataType!, e.schema)) {
205
210
  const msg =
206
211
  "initializeField: invalid subtype for field " +
207
212
  field.name +
208
213
  " expecting " +
209
214
  field.fieldType +
210
215
  " but got " +
211
- e.schema.id.toString() +
216
+ e.schema.dataTypeNodeId.toString() +
212
217
  " " +
213
218
  e.schema.name;
214
219
  errorLog(msg);
@@ -216,24 +221,24 @@ function _validateSubType(factory: DataTypeFactory, field: StructuredTypeField,
216
221
  }
217
222
  }
218
223
  }
219
- function validateSubTypeA(factory: DataTypeFactory, field: FieldType, value: any) {
224
+ function validateSubTypeA(dataTypeFactory: DataTypeFactory, field: FieldType, value: any) {
220
225
  if (field.isArray) {
221
226
  const arr = (value as unknown[]) || [];
222
227
  for (const e of arr) {
223
228
  // now check that element is of the correct type
224
- _validateSubType(factory, field, e);
229
+ _validateSubType(dataTypeFactory, field, e);
225
230
  }
226
231
  } else {
227
- _validateSubType(factory, field, value);
232
+ _validateSubType(dataTypeFactory, field, value);
228
233
  }
229
234
  }
230
235
 
231
236
  function initializeField(
232
237
  field: FieldType,
233
- thisAny: any,
238
+ thisAny: Record<string, unknown>,
234
239
  options: Record<string, unknown>,
235
240
  schema: IStructuredTypeSchema,
236
- factory: DataTypeFactory
241
+ dataTypeFactory: DataTypeFactory
237
242
  ) {
238
243
  const name = field.name;
239
244
  const value = getFieldValue(field, options);
@@ -241,7 +246,7 @@ function initializeField(
241
246
  switch (field.category) {
242
247
  case FieldCategory.complex: {
243
248
  if (field.allowSubType) {
244
- validateSubTypeA(factory, field, value);
249
+ validateSubTypeA(dataTypeFactory, field, value);
245
250
  if (field.isArray) {
246
251
  const arr = (value as unknown[]) || [];
247
252
  thisAny[name] = arr.map((x: any) => x.clone());
@@ -254,12 +259,15 @@ function initializeField(
254
259
  thisAny[name] = e.clone();
255
260
  }
256
261
  } else {
257
- const constructor = factory.getStructureTypeConstructor(field.fieldType);
262
+ const constructor = dataTypeFactory.getStructureInfoByTypeName(field.fieldType).constructor;
263
+ if (!constructor) {
264
+ throw new Error("Cannot instantiate an abstract dataType" + field.fieldType);
265
+ }
258
266
  if (field.isArray) {
259
267
  const arr = (value as unknown[]) || [];
260
268
  thisAny[name] = arr.map((x: any) => (constructor ? new constructor(x) : null));
261
269
  } else {
262
- thisAny[name] = constructor ? new constructor(value) : null;
270
+ thisAny[name] = constructor ? new constructor(value as Record<string, unknown>) : null;
263
271
  }
264
272
  }
265
273
  // getOrCreateConstructor(field.fieldType, factory) || BaseUAObject;
@@ -269,12 +277,12 @@ function initializeField(
269
277
  case FieldCategory.enumeration:
270
278
  case FieldCategory.basic:
271
279
  if (field.allowSubType) {
272
- validateSubTypeA(factory, field, value);
280
+ validateSubTypeA(dataTypeFactory, field, value);
273
281
  }
274
282
  if (field.isArray) {
275
- thisAny[name] = initialize_field_array(field, value, factory);
283
+ thisAny[name] = initialize_field_array(field, value, dataTypeFactory);
276
284
  } else {
277
- thisAny[name] = initialize_field(field, value, factory);
285
+ thisAny[name] = initialize_field(field, value, dataTypeFactory);
278
286
  }
279
287
  break;
280
288
  }
@@ -289,15 +297,16 @@ function getFieldValue(field: FieldType, options: Record<string, unknown>) {
289
297
  }
290
298
 
291
299
  function initializeFields(
292
- thisAny: any,
300
+ thisAny: Record<string, unknown>,
293
301
  options: Record<string, unknown>,
294
302
  schema: IStructuredTypeSchema,
295
- factory: DataTypeFactory,
303
+ dataTypeFactory: DataTypeFactory,
296
304
  params: InitializeFieldOptions
297
305
  ) {
306
+ const baseSchema = schema.getBaseSchema();
298
307
  // initialize base class first
299
- if (schema._baseSchema && schema._baseSchema.fields.length) {
300
- initializeFields(thisAny, options, schema._baseSchema!, factory, params);
308
+ if (baseSchema && baseSchema.fields.length) {
309
+ initializeFields(thisAny, options, baseSchema, dataTypeFactory, params);
301
310
  }
302
311
  // finding fields that are in options but not in schema!
303
312
  for (const field of schema.fields) {
@@ -309,7 +318,7 @@ function initializeFields(
309
318
  thisAny[name] = undefined;
310
319
  continue;
311
320
  }
312
- initializeField(field, thisAny, options, schema, factory);
321
+ initializeField(field, thisAny, options, schema, dataTypeFactory);
313
322
  }
314
323
  }
315
324
 
@@ -317,13 +326,15 @@ function hasOptionalFieldsF(schema: IStructuredTypeSchema): boolean {
317
326
  if (schema.bitFields && schema.bitFields.length > 0) {
318
327
  return true;
319
328
  }
320
- return schema._baseSchema ? hasOptionalFieldsF(schema._baseSchema) : false;
329
+ const baseSchema = schema.getBaseSchema();
330
+ return baseSchema ? hasOptionalFieldsF(baseSchema) : false;
321
331
  }
322
332
 
323
333
  function _internal_encodeFields(thisAny: any, schema: IStructuredTypeSchema, stream: OutputBinaryStream) {
334
+ const baseSchema = schema.getBaseSchema();
324
335
  // encodeFields base class first
325
- if (schema._baseSchema && schema._baseSchema.fields.length) {
326
- _internal_encodeFields(thisAny, schema._baseSchema!, stream);
336
+ if (baseSchema && baseSchema.fields.length) {
337
+ _internal_encodeFields(thisAny, baseSchema, stream);
327
338
  }
328
339
  for (const field of schema.fields) {
329
340
  // ignore
@@ -351,7 +362,8 @@ interface BitfieldOffset {
351
362
  allOptional: boolean;
352
363
  }
353
364
  function makeBitField(thisAny: any, schema: IStructuredTypeSchema, bo: BitfieldOffset): BitfieldOffset {
354
- const data = schema._baseSchema ? makeBitField(thisAny, schema._baseSchema, bo) : bo;
365
+ const baseSchema = schema.getBaseSchema();
366
+ const data = baseSchema ? makeBitField(thisAny, baseSchema, bo) : bo;
355
367
  let { bitField, allOptional } = data;
356
368
  const { offset } = data;
357
369
 
@@ -389,11 +401,12 @@ function internal_decodeFields(
389
401
  hasOptionalFields: boolean,
390
402
  schema: IStructuredTypeSchema,
391
403
  stream: BinaryStream,
392
- factory: DataTypeFactory
404
+ dataTypeFactory: DataTypeFactory
393
405
  ) {
406
+ const baseSchema = schema.getBaseSchema();
394
407
  // encodeFields base class first
395
- if (schema._baseSchema && schema._baseSchema.fields.length) {
396
- internal_decodeFields(thisAny, bitField, hasOptionalFields, schema._baseSchema, stream, factory);
408
+ if (baseSchema && baseSchema.fields.length) {
409
+ internal_decodeFields(thisAny, bitField, hasOptionalFields, baseSchema, stream, dataTypeFactory);
397
410
  }
398
411
  for (const field of schema.fields) {
399
412
  // ignore fields that have a switch bit when bit is not set
@@ -405,18 +418,18 @@ function internal_decodeFields(
405
418
  } else {
406
419
  if (field.category === FieldCategory.complex && thisAny[field.name] === undefined) {
407
420
  // need to create empty structure for deserialisation
408
- initializeField(field, thisAny, {}, schema, factory);
421
+ initializeField(field, thisAny, {}, schema, dataTypeFactory);
409
422
  }
410
423
  }
411
424
  }
412
425
 
413
426
  switch (field.category) {
414
427
  case FieldCategory.complex:
415
- decodeArrayOrElement(factory, field, thisAny, stream);
428
+ decodeArrayOrElement(dataTypeFactory, field, thisAny, stream);
416
429
  break;
417
430
  case FieldCategory.enumeration:
418
431
  case FieldCategory.basic:
419
- decodeArrayOrElement(factory, field, thisAny, stream, field.schema.decode);
432
+ decodeArrayOrElement(dataTypeFactory, field, thisAny, stream, field.schema.decode);
420
433
  break;
421
434
  default:
422
435
  /* istanbul ignore next*/
@@ -425,7 +438,7 @@ function internal_decodeFields(
425
438
  }
426
439
  }
427
440
 
428
- function decodeFields(thisAny: any, schema: IStructuredTypeSchema, stream: BinaryStream, factory: DataTypeFactory) {
441
+ function decodeFields(thisAny: any, schema: IStructuredTypeSchema, stream: BinaryStream, dataTypeFactory: DataTypeFactory) {
429
442
  // ============ Deal with switchBits
430
443
  const hasOptionalFields = hasOptionalFieldsF(schema);
431
444
  let bitField = 0;
@@ -433,7 +446,7 @@ function decodeFields(thisAny: any, schema: IStructuredTypeSchema, stream: Binar
433
446
  bitField = stream.readUInt32();
434
447
  }
435
448
 
436
- internal_decodeFields(thisAny, bitField, hasOptionalFields, schema, stream, factory);
449
+ internal_decodeFields(thisAny, bitField, hasOptionalFields, schema, stream, dataTypeFactory);
437
450
  }
438
451
 
439
452
  function ___fieldToJson(field: FieldType, value: any): any {
@@ -458,8 +471,9 @@ function fieldToJSON(field: FieldType, value: any): any {
458
471
  }
459
472
  }
460
473
  function encodeToJson(thisAny: any, schema: IStructuredTypeSchema, pojo: any) {
461
- if (schema._baseSchema && schema._baseSchema.fields.length) {
462
- encodeToJson(thisAny, schema._baseSchema!, pojo);
474
+ const baseSchema = schema.getBaseSchema();
475
+ if (baseSchema && baseSchema.fields.length) {
476
+ encodeToJson(thisAny, baseSchema, pojo);
463
477
  }
464
478
  for (const field of schema.fields) {
465
479
  const value = (thisAny as any)[field.name];
@@ -472,7 +486,7 @@ function encodeToJson(thisAny: any, schema: IStructuredTypeSchema, pojo: any) {
472
486
 
473
487
  interface T {
474
488
  factory?: DataTypeFactory;
475
- schema?: StructuredTypeSchema;
489
+ schema?: IStructuredTypeSchema;
476
490
  }
477
491
  const _private = new WeakMap<T>();
478
492
 
@@ -480,18 +494,18 @@ export class DynamicExtensionObject extends ExtensionObject {
480
494
  public static schema: IStructuredTypeSchema = ExtensionObject.schema;
481
495
  public static possibleFields: string[] = [];
482
496
 
483
- constructor(options: Record<string, unknown>, schema: IStructuredTypeSchema, factory: DataTypeFactory) {
497
+ constructor(options: Record<string, unknown>, schema: IStructuredTypeSchema, dataTypeFactory: DataTypeFactory) {
484
498
  assert(schema, "expecting a schema here ");
485
- assert(factory, "expecting a DataTypeFactory");
499
+ assert(dataTypeFactory, "expecting a DataTypeFactory");
486
500
 
487
501
  super(options);
488
502
  options = options || {};
489
503
 
490
- _private.set(this, { schema, factory });
504
+ _private.set(this, { schema, factory: dataTypeFactory });
491
505
 
492
506
  check_options_correctness_against_schema(this, this.schema, options);
493
507
 
494
- initializeFields(this as any, options, this.schema, factory, { caseInsensitive: true });
508
+ initializeFields(this as Record<string, unknown>, options, this.schema, dataTypeFactory, { caseInsensitive: true });
495
509
  }
496
510
 
497
511
  public encode(stream: OutputBinaryStream): void {
@@ -504,7 +518,7 @@ export class DynamicExtensionObject extends ExtensionObject {
504
518
  decodeFields(this, this.schema, stream, _private.get(this).factory);
505
519
  }
506
520
 
507
- public get schema(): StructuredTypeSchema {
521
+ public get schema(): IStructuredTypeSchema {
508
522
  const r = _private.get(this);
509
523
  return r.schema!;
510
524
  }
@@ -528,11 +542,11 @@ export type AnyConstructorFunc = AnyConstructable;
528
542
  // tslint:disable-next-line:max-classes-per-file
529
543
  class UnionBaseClass extends BaseUAObject {
530
544
  // eslint-disable-next-line max-statements
531
- constructor(options: any, schema: IStructuredTypeSchema, factory: DataTypeFactory) {
545
+ constructor(options: any, schema: IStructuredTypeSchema, dataTypeFactory: DataTypeFactory) {
532
546
  super();
533
547
 
534
548
  assert(schema, "expecting a schema here ");
535
- assert(factory, "expecting a typeDic");
549
+ assert(dataTypeFactory, "expecting a typeDic");
536
550
  options = options || {};
537
551
 
538
552
  _private.set(this, { schema });
@@ -585,12 +599,15 @@ class UnionBaseClass extends BaseUAObject {
585
599
 
586
600
  switch (field.category) {
587
601
  case FieldCategory.complex: {
588
- const constuctor = factory.getStructureTypeConstructor(field.fieldType);
602
+ const Constructor = dataTypeFactory.getStructureInfoByTypeName(field.fieldType).constructor;
603
+ if (!Constructor) {
604
+ throw new Error("Cannot instantiate an abstract dataType" + field.fieldType);
605
+ }
589
606
  // getOrCreateConstructor(field.fieldType, factory) || BaseUAObject;
590
607
  if (field.isArray) {
591
- (this as any)[name] = ((value as any) || []).map((x: any) => (constuctor ? new constuctor(x) : null));
608
+ (this as any)[name] = ((value as any) || []).map((x: any) => (Constructor ? new Constructor(x) : null));
592
609
  } else {
593
- (this as any)[name] = constuctor ? new constuctor(value) : null;
610
+ (this as any)[name] = Constructor ? new Constructor(value as Record<string, unknown>) : null;
594
611
  }
595
612
  // xx processStructuredType(fieldSchema);
596
613
  break;
@@ -659,7 +676,7 @@ class UnionBaseClass extends BaseUAObject {
659
676
  }
660
677
 
661
678
  public decode(stream: BinaryStream): void {
662
- const factory: DataTypeFactory = (this.schema as any).$$factory;
679
+ const factory = this.schema.getDataTypeFactory();
663
680
 
664
681
  const switchValue = stream.readUInt32();
665
682
  const switchFieldName = this.schema.fields[0].name;
@@ -687,7 +704,7 @@ class UnionBaseClass extends BaseUAObject {
687
704
  }
688
705
  }
689
706
 
690
- public get schema(): StructuredTypeSchema {
707
+ public get schema(): IStructuredTypeSchema {
691
708
  return _private.get(this).schema!;
692
709
  }
693
710
 
@@ -720,16 +737,22 @@ class UnionBaseClass extends BaseUAObject {
720
737
  }
721
738
  }
722
739
 
723
- function _createDynamicUnionConstructor(schema: IStructuredTypeSchema, factory: DataTypeFactory): AnyConstructorFunc {
740
+ function _createDynamicUnionConstructor(
741
+ schema: IStructuredTypeSchema,
742
+ dataTypeFactory: DataTypeFactory
743
+ ): ConstructorFuncWithSchema {
724
744
  const possibleFields = schema.fields.map((x: FieldType) => x.name);
725
745
 
726
746
  // tslint:disable-next-line:max-classes-per-file
727
747
  class UNION extends UnionBaseClass {
728
748
  public static possibleFields = possibleFields;
729
749
  public static schema = schema;
750
+ static encodingDefaultBinary: ExpandedNodeId;
751
+ static encodingDefaultXml: ExpandedNodeId;
752
+ static encodingDefaultJson?: ExpandedNodeId;
730
753
 
731
754
  constructor(options?: any) {
732
- super(options, schema, factory);
755
+ super(options, schema, dataTypeFactory);
733
756
  assert(this.schema === schema);
734
757
  }
735
758
  }
@@ -739,17 +762,19 @@ function _createDynamicUnionConstructor(schema: IStructuredTypeSchema, factory:
739
762
 
740
763
  return UNION;
741
764
  }
742
-
765
+ interface IStructuredTypeSchemaEx extends IStructuredTypeSchema {
766
+ $Constructor: any;
767
+ }
743
768
  export function createDynamicObjectConstructor(
744
769
  schema: IStructuredTypeSchema,
745
770
  dataTypeFactory: DataTypeFactory
746
- ): AnyConstructorFunc {
747
- const schemaPriv = schema as any;
771
+ ): ConstructorFuncWithSchema {
772
+ const schemaPriv = schema as IStructuredTypeSchemaEx;
748
773
 
749
774
  if (schemaPriv.$Constructor) {
750
775
  return schemaPriv.$Constructor;
751
776
  }
752
- const dataTypeNodeId = schemaPriv.id;
777
+ const dataTypeNodeId = schemaPriv.dataTypeNodeId;
753
778
 
754
779
  if (schema.baseType === "Union") {
755
780
  const UNIONConstructor = _createDynamicUnionConstructor(schema, dataTypeFactory);
@@ -771,22 +796,23 @@ export function createDynamicObjectConstructor(
771
796
  schema.baseType !== "Structure"
772
797
  ) {
773
798
  try {
774
- const baseSchema = dataTypeFactory.getStructuredTypeSchema(schema.baseType);
775
- schema._baseSchema = baseSchema;
776
- if (baseSchema.encodingDefaultBinary?.value === 0) {
799
+ const baseSchema = schema.getBaseSchema(); // dataTypeFactory.getStructuredTypeSchema(schema.baseType);
800
+ if (!baseSchema || baseSchema.encodingDefaultBinary?.value === 0) {
777
801
  // is abstract
778
802
  } else {
779
- BaseClass = getOrCreateConstructor(schema.baseType, dataTypeFactory);
780
- if (!BaseClass) {
781
- throw new Error("Cannot find base class : " + schema.baseType);
782
- }
783
- if ((BaseClass as any).possibleFields) {
784
- possibleFields = (BaseClass as any).possibleFields.concat(possibleFields);
803
+ if (!baseSchema.isAbstract) {
804
+ // to do : check this
805
+ BaseClass = getOrCreateConstructor(schema.baseType, dataTypeFactory);
806
+ if (!BaseClass) {
807
+ throw new Error("Cannot find base class : " + schema.baseType);
808
+ }
809
+ if ((BaseClass as any).possibleFields) {
810
+ possibleFields = (BaseClass as any).possibleFields.concat(possibleFields);
811
+ }
785
812
  }
786
- schema._baseSchema = BaseClass.schema;
787
813
  }
788
814
  } catch (err) {
789
- // xx console.log("createDynamicObjectConstructor err= ", err.message);
815
+ console.log("createDynamicObjectConstructor err= ", (err as Error).message);
790
816
  }
791
817
  }
792
818
 
@@ -822,10 +848,9 @@ export function createDynamicObjectConstructor(
822
848
 
823
849
  // to do : may be remove DataType suffix here ?
824
850
  Object.defineProperty(EXTENSION, "name", { value: schema.name });
825
-
826
851
  schemaPriv.$Constructor = EXTENSION;
827
- (EXTENSION as any).encodingDefaultBinary = schema.encodingDefaultBinary;
828
- dataTypeFactory.registerClassDefinition(dataTypeNodeId, schema.name, EXTENSION as any);
852
+ EXTENSION.encodingDefaultBinary = schema.encodingDefaultBinary!;
853
+ dataTypeFactory.registerClassDefinition(dataTypeNodeId, schema.name, EXTENSION as ConstructorFuncWithSchema);
829
854
 
830
- return EXTENSION;
855
+ return EXTENSION as ConstructorFuncWithSchema;
831
856
  }