node-opcua-xml2json 2.71.0 → 2.73.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.
@@ -1,29 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Xml2JsonPojo = exports.startPojo = exports.json_parser = void 0;
4
- const xml2json_1 = require("./xml2json");
5
- const xml2Json_pojo_tools_1 = require("./xml2Json_pojo_tools");
6
- const json_extractor = new xml2Json_pojo_tools_1.ReaderState2();
7
- exports.json_parser = {
8
- init(elementName, attrs, parent, engine) {
9
- json_extractor._on_init(elementName, attrs, parent, 0, engine);
10
- },
11
- finish() {
12
- this.parent._pojo = json_extractor._pojo;
13
- }
14
- };
15
- function startPojo(pThis, elementName, attrs, withPojo) {
16
- pThis.engine._promote(json_extractor, pThis.engine.currentLevel, elementName, attrs);
17
- json_extractor._withPojo = (name, pojo) => {
18
- withPojo(name, pojo);
19
- pThis.engine._demote(json_extractor, pThis.engine.currentLevel, elementName);
20
- };
21
- }
22
- exports.startPojo = startPojo;
23
- class Xml2JsonPojo extends xml2json_1.Xml2Json {
24
- constructor() {
25
- super(json_extractor);
26
- }
27
- }
28
- exports.Xml2JsonPojo = Xml2JsonPojo;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Xml2JsonPojo = exports.startPojo = exports.json_parser = void 0;
4
+ const xml2json_1 = require("./xml2json");
5
+ const xml2Json_pojo_tools_1 = require("./xml2Json_pojo_tools");
6
+ const json_extractor = new xml2Json_pojo_tools_1.ReaderState2();
7
+ exports.json_parser = {
8
+ init(elementName, attrs, parent, engine) {
9
+ json_extractor._on_init(elementName, attrs, parent, 0, engine);
10
+ },
11
+ finish() {
12
+ this.parent._pojo = json_extractor._pojo;
13
+ }
14
+ };
15
+ function startPojo(pThis, elementName, attrs, withPojo) {
16
+ pThis.engine._promote(json_extractor, pThis.engine.currentLevel, elementName, attrs);
17
+ json_extractor._withPojo = (name, pojo) => {
18
+ withPojo(name, pojo);
19
+ pThis.engine._demote(json_extractor, pThis.engine.currentLevel, elementName);
20
+ };
21
+ }
22
+ exports.startPojo = startPojo;
23
+ class Xml2JsonPojo extends xml2json_1.Xml2Json {
24
+ constructor() {
25
+ super(json_extractor);
26
+ }
27
+ }
28
+ exports.Xml2JsonPojo = Xml2JsonPojo;
29
29
  //# sourceMappingURL=xml2json_pojo.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-xml2json",
3
- "version": "2.71.0",
3
+ "version": "2.73.0",
4
4
  "description": "pure nodejs OPCUA SDK - module -xml2json",
5
5
  "main": "dist/source/index.js",
6
6
  "types": "dist/source/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "author": "Etienne Rossignon",
23
23
  "license": "MIT",
24
24
  "devDependencies": {
25
- "node-opcua-nodesets": "2.71.0",
25
+ "node-opcua-nodesets": "2.73.0",
26
26
  "should": "^13.2.3"
27
27
  },
28
28
  "repository": {
@@ -38,5 +38,5 @@
38
38
  "internet of things"
39
39
  ],
40
40
  "homepage": "http://node-opcua.github.io/",
41
- "gitHead": "10f7cc1e1cd30dfef75adad9cb709a78401fabf3"
41
+ "gitHead": "b23a87c1ef777c0d8b680f45ee77e2a319feb092"
42
42
  }
@@ -1,5 +1,5 @@
1
- // <Definition Name="SomeName">
2
- // <Field Name="Running" Value="0" dataType: [ValueRank="1"]>
1
+ //<Definition Name="SomeName">
2
+ // <Field Name="Running" Value="0" dataType: [ValueRank="1"]>
3
3
  // [<Description>text</Description>]
4
4
  // <Field>
5
5
  // </Definition>
@@ -7,7 +7,7 @@ import assert from "node-opcua-assert";
7
7
  import { ReaderStateParserLike, XmlAttributes } from "./xml2json";
8
8
 
9
9
  // <Definition Name="SomeName">
10
- // <Field Name="Running" Value="0" dataType: [ValueRank="1"]>
10
+ // <Field Name="Running" Value="0" dataType: [ValueRank="1"]>
11
11
  // [<Description>text</Description>]
12
12
  // <Field>
13
13
  // </Definition>
@@ -17,9 +17,41 @@ import { ReaderStateParserLike, XmlAttributes } from "./xml2json";
17
17
  // (IsOptionSet)
18
18
  //
19
19
  //
20
+ type UAString = string |null;
21
+ type NodeIdLike = string | null;
22
+ type Int32 = number;
23
+ type UInt32 = number;
24
+ type UABoolean = boolean;
25
+ type LocalizedTextLike = string | null;
26
+
27
+ export interface StructureFieldOptions {
28
+ name?: UAString ;
29
+ description?: (LocalizedTextLike | null);
30
+ dataType?: (NodeIdLike | null);
31
+ valueRank?: Int32 ;
32
+ arrayDimensions?: UInt32 [] | null;
33
+ maxStringLength?: UInt32 ;
34
+ isOptional?: UABoolean ;
35
+ }
36
+ interface AA {
37
+ parent: {
38
+ definitionFields: StructureFieldOptions[];
39
+ nFields: number;
40
+ definitionName: string;
41
+
42
+ },
43
+ array: StructureFieldOptions[];
44
+ isUnion: boolean;
45
+ }
46
+ interface FieldParser {
47
+ description?: (LocalizedTextLike | null);
48
+ parent: AA;
49
+ attrs: Record<string, string>;
50
+ }
20
51
  export const _definitionParser: ReaderStateParserLike = {
21
- init(this: any, name: string, attrs: XmlAttributes) {
22
- assert(!this.parent.definitionFields || this.parent.definitionFields.length === 0);
52
+ init(this: AA, name: string, attrs: XmlAttributes) {
53
+ assert(!this.parent.
54
+ nFields || this.parent.definitionFields.length === 0);
23
55
  this.parent.definitionFields = [];
24
56
  this.parent.definitionName = attrs.SymbolicName || attrs.Name;
25
57
  this.array = this.parent.definitionFields;
@@ -27,7 +59,7 @@ export const _definitionParser: ReaderStateParserLike = {
27
59
  },
28
60
  parser: {
29
61
  Field: {
30
- init(this: any) {
62
+ init(this: FieldParser) {
31
63
  this.description = undefined;
32
64
  },
33
65
  parser: {
@@ -37,10 +69,15 @@ export const _definitionParser: ReaderStateParserLike = {
37
69
  }
38
70
  }
39
71
  },
40
- finish(this: any) {
72
+ finish(this: FieldParser) {
41
73
  const obj: any = {
42
74
  name: this.attrs.Name
43
75
  };
76
+ if (this.attrs.AllowSubtype !== undefined) {
77
+ obj.allowSubtype = this.attrs.AllowSubtype === "true";
78
+ } else {
79
+ obj.allowSubtype = false;
80
+ }
44
81
  if (this.attrs.DataType !== undefined) {
45
82
  obj.dataType = this.attrs.DataType;
46
83
  }
@@ -172,6 +172,7 @@ interface Field {
172
172
  name: string;
173
173
  value?: any;
174
174
  valueRank?: number; // default is -1 => scalar
175
+ allowSubtype?: boolean;
175
176
  }
176
177
 
177
178
  export interface Definition {
@@ -265,7 +266,7 @@ function _makeExtensionObjectReader(
265
266
  listReader.parser![field.dataType] = fieldReader;
266
267
  reader.parser![field.name] = listReader;
267
268
  } else {
268
- throw new Error("Unsupported ValueRank !");
269
+ throw new Error("Unsupported ValueRank ! " + field.valueRank);
269
270
  }
270
271
  }
271
272
  // xx const parser: ParserLike = {};