node-opcua-factory 2.78.0 → 2.81.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.
Files changed (31) hide show
  1. package/package.json +5 -5
  2. package/dist/constructor_type.d.ts +0 -15
  3. package/dist/constructor_type.js +0 -3
  4. package/dist/constructor_type.js.map +0 -1
  5. package/dist/factories_baseobject.d.ts +0 -56
  6. package/dist/factories_baseobject.js +0 -535
  7. package/dist/factories_baseobject.js.map +0 -1
  8. package/dist/factories_basic_type.d.ts +0 -40
  9. package/dist/factories_basic_type.js +0 -136
  10. package/dist/factories_basic_type.js.map +0 -1
  11. package/dist/factories_builtin_types.d.ts +0 -32
  12. package/dist/factories_builtin_types.js +0 -262
  13. package/dist/factories_builtin_types.js.map +0 -1
  14. package/dist/factories_builtin_types_special.d.ts +0 -5
  15. package/dist/factories_builtin_types_special.js +0 -46
  16. package/dist/factories_builtin_types_special.js.map +0 -1
  17. package/dist/factories_enumerations.d.ts +0 -31
  18. package/dist/factories_enumerations.js +0 -78
  19. package/dist/factories_enumerations.js.map +0 -1
  20. package/dist/factories_factories.d.ts +0 -17
  21. package/dist/factories_factories.js +0 -54
  22. package/dist/factories_factories.js.map +0 -1
  23. package/dist/factories_id_generator.d.ts +0 -3
  24. package/dist/factories_id_generator.js +0 -22
  25. package/dist/factories_id_generator.js.map +0 -1
  26. package/dist/factories_schema_helpers.d.ts +0 -27
  27. package/dist/factories_schema_helpers.js +0 -122
  28. package/dist/factories_schema_helpers.js.map +0 -1
  29. package/dist/factories_structuredTypeSchema.d.ts +0 -45
  30. package/dist/factories_structuredTypeSchema.js +0 -277
  31. package/dist/factories_structuredTypeSchema.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-factory",
3
- "version": "2.78.0",
3
+ "version": "2.81.0",
4
4
  "description": "pure nodejs OPCUA SDK - module -factory",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -17,13 +17,13 @@
17
17
  "dependencies": {
18
18
  "chalk": "4.1.2",
19
19
  "node-opcua-assert": "2.77.0",
20
- "node-opcua-basic-types": "2.77.0",
20
+ "node-opcua-basic-types": "2.81.0",
21
21
  "node-opcua-binary-stream": "2.77.0",
22
22
  "node-opcua-constants": "2.77.0",
23
23
  "node-opcua-debug": "2.77.0",
24
24
  "node-opcua-enum": "2.77.0",
25
- "node-opcua-guid": "2.77.0",
26
- "node-opcua-nodeid": "2.77.0",
25
+ "node-opcua-guid": "2.81.0",
26
+ "node-opcua-nodeid": "2.81.0",
27
27
  "node-opcua-status-code": "2.77.0",
28
28
  "node-opcua-utils": "2.77.0"
29
29
  },
@@ -42,5 +42,5 @@
42
42
  "internet of things"
43
43
  ],
44
44
  "homepage": "http://node-opcua.github.io/",
45
- "gitHead": "31c6eee3c51f52427584364fff2fdb07bbac65be"
45
+ "gitHead": "fd89928bc4a4b9f31a6b6e5921f743e8284eba2b"
46
46
  }
@@ -1,15 +0,0 @@
1
- /**
2
- * @module node-opcua-factory
3
- */
4
- import { ExpandedNodeId } from "node-opcua-nodeid";
5
- import { BaseUAObject } from "./factories_baseobject";
6
- import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
7
- declare type BaseUAObjectConstructable = new (options?: any) => BaseUAObject;
8
- export declare type ConstructorFunc = BaseUAObjectConstructable;
9
- export interface ConstructorFuncWithSchema extends ConstructorFunc {
10
- schema: StructuredTypeSchema;
11
- possibleFields: string[];
12
- encodingDefaultBinary: ExpandedNodeId;
13
- encodingDefaultXml: ExpandedNodeId;
14
- }
15
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=constructor_type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constructor_type.js","sourceRoot":"","sources":["../source/constructor_type.ts"],"names":[],"mappings":""}
@@ -1,56 +0,0 @@
1
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
- import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
3
- export interface DecodeDebugOptions {
4
- tracer: any;
5
- name: string;
6
- }
7
- export interface BaseUAObject {
8
- schema: StructuredTypeSchema;
9
- }
10
- /**
11
- * @class BaseUAObject
12
- * @constructor
13
- */
14
- export declare class BaseUAObject {
15
- constructor();
16
- /**
17
- * Encode the object to the binary stream.
18
- * @class BaseUAObject
19
- * @method encode
20
- * @param stream {BinaryStream}
21
- */
22
- encode(stream: OutputBinaryStream): void;
23
- /**
24
- * Decode the object from the binary stream.
25
- * @class BaseUAObject
26
- * @method decode
27
- * @param stream {BinaryStream}
28
- */
29
- decode(stream: BinaryStream): void;
30
- /**
31
- * Calculate the required size to store this object in a binary stream.
32
- * @method binaryStoreSize
33
- * @return number
34
- */
35
- binaryStoreSize(): number;
36
- /**
37
- * @method toString
38
- * @return {String}
39
- */
40
- toString(...args: any[]): string;
41
- /**
42
- *
43
- * verify that all object attributes values are valid according to schema
44
- * @method isValid
45
- * @return boolean
46
- */
47
- isValid(): boolean;
48
- /**
49
- * @method decodeDebug
50
- *
51
- */
52
- decodeDebug(stream: BinaryStream, options: DecodeDebugOptions): void;
53
- explore(): string;
54
- toJSON(): any;
55
- clone(): any;
56
- }
@@ -1,535 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.BaseUAObject = void 0;
5
- /* eslint-disable prefer-rest-params */
6
- /* eslint-disable complexity */
7
- /**
8
- * @module node-opcua-factory
9
- */
10
- // tslint:disable:no-shadowed-variable
11
- const chalk = require("chalk");
12
- const node_opcua_assert_1 = require("node-opcua-assert");
13
- const node_opcua_basic_types_1 = require("node-opcua-basic-types");
14
- const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
15
- const node_opcua_debug_1 = require("node-opcua-debug");
16
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
17
- const utils = require("node-opcua-utils");
18
- const factories_builtin_types_1 = require("./factories_builtin_types");
19
- const factories_enumerations_1 = require("./factories_enumerations");
20
- const factories_factories_1 = require("./factories_factories");
21
- const factories_structuredTypeSchema_1 = require("./factories_structuredTypeSchema");
22
- const types_1 = require("./types");
23
- function r(str, length = 30) {
24
- return (str + " ").substring(0, length);
25
- }
26
- function _decode_member_(value, field, stream, options) {
27
- const tracer = options.tracer;
28
- const cursorBefore = stream.length;
29
- const fieldType = field.fieldType;
30
- switch (field.category) {
31
- case types_1.FieldCategory.basic:
32
- if (field.schema.decode) {
33
- value = field.schema.decode(stream);
34
- }
35
- tracer.trace("member", options.name, value, cursorBefore, stream.length, fieldType);
36
- break;
37
- case types_1.FieldCategory.enumeration:
38
- if (field.schema.decode) {
39
- value = field.schema.decode(stream);
40
- }
41
- tracer.trace("member", options.name, value, cursorBefore, stream.length, fieldType);
42
- break;
43
- case types_1.FieldCategory.complex: {
44
- (0, node_opcua_assert_1.assert)(field.category === types_1.FieldCategory.complex);
45
- if (!field.fieldTypeConstructor) {
46
- field.fieldTypeConstructor = (0, factories_factories_1.getStructureTypeConstructor)(field.fieldType);
47
- }
48
- if (typeof field.fieldTypeConstructor !== "function") {
49
- throw new Error("Cannot find constructor for " + field.name + "of type " + field.fieldType);
50
- }
51
- // assert(typeof field.fieldTypeConstructor === "function");
52
- const constructor = field.fieldTypeConstructor;
53
- value = new constructor();
54
- value.decodeDebug(stream, options);
55
- }
56
- }
57
- return value;
58
- }
59
- function applyOnAllSchemaFields(self, schema, data, functor, args) {
60
- const baseSchema = (0, factories_structuredTypeSchema_1.get_base_schema)(schema);
61
- if (baseSchema) {
62
- applyOnAllSchemaFields(self, baseSchema, data, functor, args);
63
- }
64
- for (const field of schema.fields) {
65
- functor(self, field, data, args);
66
- }
67
- }
68
- const _nbElements = typeof process === "object" ? (process.env.ARRAYLENGTH ? parseInt(process.env.ARRAYLENGTH, 10) : 10) : 10;
69
- const fullBuffer = typeof process === "object" ? !!((_a = process.env) === null || _a === void 0 ? void 0 : _a.FULLBUFFER) : false;
70
- function _arrayEllipsis(value, data) {
71
- if (!value) {
72
- return "null []";
73
- }
74
- else {
75
- if (value.length === 0) {
76
- return "[ /* empty*/ ]";
77
- }
78
- (0, node_opcua_assert_1.assert)(Array.isArray(value));
79
- const v = [];
80
- const m = Math.min(_nbElements, value.length);
81
- const ellipsis = value.length > _nbElements ? " ... " : "";
82
- const pad = data.padding + " ";
83
- let isMultiLine = true;
84
- for (let i = 0; i < m; i++) {
85
- let element = value[i];
86
- if (element instanceof Buffer) {
87
- element = (0, node_opcua_debug_1.hexDump)(element, 32, 16);
88
- }
89
- else if (utils.isNullOrUndefined(element)) {
90
- element = "null";
91
- }
92
- else {
93
- element = element.toString();
94
- const s = element.split("\n");
95
- if (s.length > 1) {
96
- element = "\n" + pad + s.join("\n" + pad);
97
- isMultiLine = true;
98
- }
99
- }
100
- if (element.length > 80) {
101
- isMultiLine = true;
102
- }
103
- v.push(element);
104
- }
105
- const length = "/* length =" + value.length + "*/";
106
- if (isMultiLine) {
107
- return "[ " + length + "\n" + pad + v.join(",\n" + pad + " ") + ellipsis + "\n" + data.padding + "]";
108
- }
109
- else {
110
- return "[ " + length + v.join(",") + ellipsis + "]";
111
- }
112
- }
113
- }
114
- // eslint-disable-next-line complexity
115
- // eslint-disable-next-line max-statements
116
- function _exploreObject(self, field, data, args) {
117
- if (!self) {
118
- return;
119
- }
120
- (0, node_opcua_assert_1.assert)(self);
121
- const fieldType = field.fieldType;
122
- const fieldName = field.name;
123
- const category = field.category;
124
- const padding = data.padding;
125
- let value = self[fieldName];
126
- let str;
127
- // decorate the field name with ?# if the field is optional
128
- let opt = " ";
129
- if (field.switchBit !== undefined) {
130
- opt = " ?" + field.switchBit + " ";
131
- }
132
- if (field.switchValue !== undefined) {
133
- opt = " !" + field.switchValue + " ";
134
- }
135
- const fieldNameF = chalk.yellow(r(padding + fieldName, 30));
136
- const fieldTypeF = chalk.cyan("/* " + r(fieldType + opt, 17) + (field.isArray ? "[]" : " ") + " */");
137
- // detected when optional field is not specified in value
138
- if (field.switchBit !== undefined && value === undefined) {
139
- str = fieldNameF + " " + fieldTypeF + ": " + chalk.italic.grey("undefined") + " /* optional field not specified */";
140
- data.lines.push(str);
141
- return;
142
- }
143
- // detected when union field is not specified in value
144
- if (field.switchValue !== undefined && value === undefined) {
145
- str = fieldNameF + " " + fieldTypeF + ": " + chalk.italic.grey("undefined") + " /* union field not specified */";
146
- data.lines.push(str);
147
- return;
148
- }
149
- // compact version of very usual objects
150
- if (fieldType === "QualifiedName" && !field.isArray && value) {
151
- value = value.toString() || "<null>";
152
- str = fieldNameF + " " + fieldTypeF + ": " + chalk.green(value.toString());
153
- data.lines.push(str);
154
- return;
155
- }
156
- if (fieldType === "LocalizedText" && !field.isArray && value) {
157
- value = value.toString() || "<null>";
158
- str = fieldNameF + " " + fieldTypeF + ": " + chalk.green(value.toString());
159
- data.lines.push(str);
160
- return;
161
- }
162
- if (fieldType === "DataValue" && !field.isArray && value) {
163
- value = value.toString(data);
164
- str = fieldNameF + " " + fieldTypeF + ": " + chalk.green(value.toString(data));
165
- data.lines.push(str);
166
- return;
167
- }
168
- function _dump_enumeration_value(self, field, data, value, fieldType) {
169
- const s = field.schema;
170
- // istanbul ignore next
171
- if (!s.typedEnum) {
172
- // tslint:disable:no-console
173
- console.log("xxxx cannot find typeEnum", s);
174
- }
175
- const convert = (value) => {
176
- // istanbul ignore next
177
- if (!s.typedEnum.get(value)) {
178
- return [value, s.typedEnum.get(value)];
179
- }
180
- else {
181
- return [value, s.typedEnum.get(value).key];
182
- }
183
- };
184
- const toS = ([n, s]) => `${n} /*(${s})*/`;
185
- if (field.isArray) {
186
- str =
187
- fieldNameF +
188
- " " +
189
- fieldTypeF +
190
- ": [" +
191
- value
192
- .map((c) => convert(c))
193
- .map(toS)
194
- .join(", ") +
195
- "]";
196
- data.lines.push(str);
197
- }
198
- else {
199
- const c = convert(value);
200
- str = `${fieldNameF} ${fieldTypeF}: ${toS(c)}`;
201
- data.lines.push(str);
202
- }
203
- }
204
- function _dump_simple_value(self, field, data, value, fieldType) {
205
- let str = "";
206
- if (value instanceof Buffer) {
207
- data.lines.push(fieldNameF + " " + fieldTypeF);
208
- if (fullBuffer || value.length <= 32) {
209
- const _hexDump = value.length <= 32 ? "Ox" + value.toString("hex") : "\n" + (0, node_opcua_debug_1.hexDump)(value);
210
- data.lines.push("Buffer: " + _hexDump);
211
- }
212
- else {
213
- const _hexDump1 = value.slice(0, 16).toString("hex");
214
- const _hexDump2 = value.slice(-16).toString("hex");
215
- data.lines.push("Buffer: ", _hexDump1 + "..." + _hexDump2);
216
- }
217
- }
218
- else {
219
- if (field.isArray) {
220
- str = fieldNameF + " " + fieldTypeF + ": " + _arrayEllipsis(value, data);
221
- }
222
- else {
223
- if (field.fieldType === "NodeId" && value instanceof node_opcua_nodeid_1.NodeId) {
224
- value = value.displayText();
225
- }
226
- else if (fieldType === "IntegerId" || fieldType === "UInt32") {
227
- if (field.name === "attributeId") {
228
- value = "AttributeIds." + node_opcua_basic_types_1.AttributeIds[value] + "/* " + value + " */";
229
- }
230
- else {
231
- const extra = value !== undefined ? "0x" + value.toString(16) : "undefined";
232
- value = "" + value + " " + extra;
233
- }
234
- }
235
- else if (fieldType === "DateTime" || fieldType === "UtcTime") {
236
- try {
237
- value = value && value.toISOString ? value.toISOString() : value;
238
- }
239
- catch (_a) {
240
- value = chalk.red((value === null || value === void 0 ? void 0 : value.toString()) + " *** ERROR ***");
241
- }
242
- }
243
- else if (typeof value === "object" && value !== null && value !== undefined) {
244
- // eslint-disable-next-line prefer-spread
245
- value = value.toString.apply(value, args);
246
- }
247
- str =
248
- fieldNameF +
249
- " " +
250
- fieldTypeF +
251
- ": " +
252
- (value === null || value === undefined ? chalk.blue("null") : value.toString());
253
- }
254
- data.lines.push(str);
255
- }
256
- }
257
- function _dump_complex_value(self, field, data, value, fieldType) {
258
- if (field.subType) {
259
- // this is a synonymous
260
- fieldType = field.subType;
261
- _dump_simple_value(self, field, data, value, fieldType);
262
- }
263
- else {
264
- const typeDictionary = self.schema.$$factory;
265
- // istanbul ignore next
266
- if (!typeDictionary) {
267
- // tslint:disable-next-line: no-console
268
- console.log(" No typeDictionary for ", self.schema);
269
- return;
270
- }
271
- field.fieldTypeConstructor = field.fieldTypeConstructor || typeDictionary.getStructureTypeConstructor(fieldType);
272
- const fieldTypeConstructor = field.fieldTypeConstructor;
273
- const _newFieldSchema = field.schema ||
274
- fieldTypeConstructor.prototype.schema ||
275
- fieldTypeConstructor.schema;
276
- if (field.isArray) {
277
- if (value === null) {
278
- data.lines.push(fieldNameF + " " + fieldTypeF + ": null []");
279
- }
280
- else if (value.length === 0) {
281
- data.lines.push(fieldNameF + " " + fieldTypeF + ": [ /* empty */ ]");
282
- }
283
- else {
284
- data.lines.push(fieldNameF + " " + fieldTypeF + ": [");
285
- const m = Math.min(_nbElements, value.length);
286
- for (let i = 0; i < m; i++) {
287
- const element = value[i];
288
- data.lines.push(padding + chalk.cyan(" { " + ("/*" + i + "*/")));
289
- const data1 = {
290
- lines: [],
291
- padding: padding + " "
292
- };
293
- applyOnAllSchemaFields(element, _newFieldSchema, data1, _exploreObject, args);
294
- data.lines = data.lines.concat(data1.lines);
295
- data.lines.push(padding + " }" + (i === value.length - 1 ? "" : ","));
296
- }
297
- if (m < value.length) {
298
- data.lines.push(padding + " ..... ( " + value.length + " elements )");
299
- }
300
- data.lines.push(padding + "]");
301
- }
302
- }
303
- else {
304
- data.lines.push(fieldNameF + " " + fieldTypeF + ": {");
305
- const data1 = { padding: padding + " ", lines: [] };
306
- applyOnAllSchemaFields(value, _newFieldSchema, data1, _exploreObject, args);
307
- data.lines = data.lines.concat(data1.lines);
308
- data.lines.push(padding + "}");
309
- }
310
- }
311
- }
312
- switch (category) {
313
- case types_1.FieldCategory.enumeration:
314
- _dump_enumeration_value(self, field, data, value, fieldType);
315
- break;
316
- case types_1.FieldCategory.basic:
317
- _dump_simple_value(self, field, data, value, fieldType);
318
- break;
319
- case types_1.FieldCategory.complex:
320
- _dump_complex_value(self, field, data, value, fieldType);
321
- break;
322
- default:
323
- throw new Error("internal error: unknown kind_of_field " + category);
324
- }
325
- }
326
- function json_ify(t, value, fieldType) {
327
- if (value instanceof Array) {
328
- return value.map((e) => (e && e.toJSON ? e.toJSON() : e));
329
- }
330
- /*
331
- if (typeof fieldType.toJSON === "function") {
332
- return fieldType.toJSON(value);
333
- } else
334
- */
335
- if (t && t.toJSON) {
336
- return t.toJSON(value);
337
- }
338
- else if (value.toJSON) {
339
- return value.toJSON();
340
- }
341
- else {
342
- return value;
343
- }
344
- }
345
- function _JSONify(self, schema, pojo) {
346
- /* jshint validthis: true */
347
- for (const field of schema.fields) {
348
- const fieldValue = self[field.name];
349
- if (fieldValue === null || fieldValue === undefined) {
350
- continue;
351
- }
352
- if ((0, factories_enumerations_1.hasEnumeration)(field.fieldType)) {
353
- const enumeration = (0, factories_enumerations_1.getEnumeration)(field.fieldType);
354
- (0, node_opcua_assert_1.assert)(enumeration !== null);
355
- if (field.isArray) {
356
- pojo[field.name] = fieldValue.map((value) => enumeration.enumValues[value.toString()]);
357
- }
358
- else {
359
- pojo[field.name] = enumeration.enumValues[fieldValue.toString()];
360
- }
361
- continue;
362
- }
363
- const t = (0, factories_builtin_types_1.getBuildInType)(field.fieldType);
364
- if (field.isArray) {
365
- pojo[field.name] = fieldValue.map((value) => json_ify(t, value, field));
366
- }
367
- else {
368
- pojo[field.name] = json_ify(t, fieldValue, field);
369
- }
370
- }
371
- }
372
- /**
373
- * @class BaseUAObject
374
- * @constructor
375
- */
376
- class BaseUAObject {
377
- constructor() {
378
- /** */
379
- }
380
- /**
381
- * Encode the object to the binary stream.
382
- * @class BaseUAObject
383
- * @method encode
384
- * @param stream {BinaryStream}
385
- */
386
- encode(stream) {
387
- /** */
388
- }
389
- /**
390
- * Decode the object from the binary stream.
391
- * @class BaseUAObject
392
- * @method decode
393
- * @param stream {BinaryStream}
394
- */
395
- decode(stream) {
396
- /** */
397
- }
398
- /**
399
- * Calculate the required size to store this object in a binary stream.
400
- * @method binaryStoreSize
401
- * @return number
402
- */
403
- binaryStoreSize() {
404
- const stream = new node_opcua_binary_stream_1.BinaryStreamSizeCalculator();
405
- this.encode(stream);
406
- return stream.length;
407
- }
408
- /**
409
- * @method toString
410
- * @return {String}
411
- */
412
- toString(...args) {
413
- if (this.schema && Object.prototype.hasOwnProperty.call(this.schema, "toString")) {
414
- return this.schema.toString.apply(this, arguments);
415
- }
416
- else {
417
- if (!this.explore) {
418
- // xx console.log(util.inspect(this));
419
- return Object.prototype.toString.apply(this, arguments);
420
- }
421
- return this.explore();
422
- }
423
- }
424
- /**
425
- *
426
- * verify that all object attributes values are valid according to schema
427
- * @method isValid
428
- * @return boolean
429
- */
430
- isValid() {
431
- (0, node_opcua_assert_1.assert)(this.schema);
432
- if (this.schema.isValid) {
433
- return this.schema.isValid(this);
434
- }
435
- else {
436
- return true;
437
- }
438
- }
439
- /**
440
- * @method decodeDebug
441
- *
442
- */
443
- decodeDebug(stream, options) {
444
- const tracer = options.tracer;
445
- const schema = this.schema;
446
- tracer.trace("start", options.name + "(" + schema.name + ")", stream.length, stream.length);
447
- const self = this;
448
- for (const field of schema.fields) {
449
- const value = self[field.name];
450
- if (typeof field.switchValue === "number") {
451
- // skip
452
- if (self["switchField"] !== field.switchValue) {
453
- continue;
454
- }
455
- }
456
- if (field.isArray) {
457
- const cursorBefore = stream.length;
458
- let nb = stream.readUInt32();
459
- if (nb === 0xffffffff) {
460
- nb = 0;
461
- }
462
- options.name = field.name + [];
463
- tracer.trace("start_array", field.name, nb, cursorBefore, stream.length);
464
- for (let i = 0; i < nb; i++) {
465
- tracer.trace("start_element", field.name, i);
466
- options.name = "element #" + i;
467
- _decode_member_(value, field, stream, options);
468
- tracer.trace("end_element", field.name, i);
469
- }
470
- tracer.trace("end_array", field.name, stream.length - 4);
471
- }
472
- else {
473
- options.name = field.name;
474
- _decode_member_(value, field, stream, options);
475
- }
476
- }
477
- tracer.trace("end", schema.name, stream.length, stream.length);
478
- }
479
- explore() {
480
- const data = {
481
- lines: [],
482
- padding: " "
483
- };
484
- data.lines.push("{" + chalk.cyan(" /*" + (this.schema ? this.schema.name : "") + "*/"));
485
- if (this.schema) {
486
- applyOnAllSchemaFields(this, this.schema, data, _exploreObject, arguments);
487
- }
488
- data.lines.push("};");
489
- return data.lines.join("\n");
490
- }
491
- toJSON() {
492
- (0, node_opcua_assert_1.assert)(this.schema);
493
- if (this.schema.toJSON) {
494
- return this.schema.toJSON.apply(this, arguments);
495
- }
496
- else {
497
- (0, node_opcua_assert_1.assert)(this.schema);
498
- const schema = this.schema;
499
- const pojo = {};
500
- _visitSchemaChain(this, schema, pojo, _JSONify, null);
501
- return pojo;
502
- }
503
- }
504
- clone( /*options,optionalFilter,extraInfo*/) {
505
- const self = this;
506
- const params = {};
507
- function construct_param(schema, options) {
508
- for (const field of schema.fields) {
509
- const f = self[field.name];
510
- if (f === null || f === undefined) {
511
- continue;
512
- }
513
- if (field.isArray) {
514
- options[field.name] = self[field.name];
515
- }
516
- else {
517
- options[field.name] = self[field.name];
518
- }
519
- }
520
- }
521
- construct_param.call(this, self.schema, params);
522
- return new self.constructor(params);
523
- }
524
- }
525
- exports.BaseUAObject = BaseUAObject;
526
- function _visitSchemaChain(self, schema, pojo, func, extraData) {
527
- (0, node_opcua_assert_1.assert)(typeof func === "function");
528
- // apply also construct to baseType schema first
529
- const baseSchema = (0, factories_structuredTypeSchema_1.get_base_schema)(schema);
530
- if (baseSchema) {
531
- _visitSchemaChain(self, baseSchema, pojo, func, extraData);
532
- }
533
- func.call(null, self, schema, pojo);
534
- }
535
- //# sourceMappingURL=factories_baseobject.js.map