node-opcua-xml2json 2.63.1 → 2.64.1

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,3 +1,3 @@
1
- import { ReaderStateParserLike } from "./xml2json";
2
- export declare const _definitionParser: ReaderStateParserLike;
3
- export declare const definitionReaderStateParser: ReaderStateParserLike;
1
+ import { ReaderStateParserLike } from "./xml2json";
2
+ export declare const _definitionParser: ReaderStateParserLike;
3
+ export declare const definitionReaderStateParser: ReaderStateParserLike;
@@ -1,84 +1,84 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.definitionReaderStateParser = exports._definitionParser = void 0;
4
- // <Definition Name="SomeName">
5
- // <Field Name="Running" Value="0" dataType: [ValueRank="1"]>
6
- // [<Description>text</Description>]
7
- // <Field>
8
- // </Definition>
9
- const node_opcua_assert_1 = require("node-opcua-assert");
10
- // <Definition Name="SomeName">
11
- // <Field Name="Running" Value="0" dataType: [ValueRank="1"]>
12
- // [<Description>text</Description>]
13
- // <Field>
14
- // </Definition>
15
- //
16
- // Or
17
- //
18
- // (IsOptionSet)
19
- //
20
- //
21
- exports._definitionParser = {
22
- init(name, attrs) {
23
- (0, node_opcua_assert_1.default)(!this.parent.definitionFields || this.parent.definitionFields.length === 0);
24
- this.parent.definitionFields = [];
25
- this.parent.definitionName = attrs.SymbolicName || attrs.Name;
26
- this.array = this.parent.definitionFields;
27
- this.isUnion = attrs.IsUnion === "true" ? true : false;
28
- },
29
- parser: {
30
- Field: {
31
- init() {
32
- this.description = undefined;
33
- },
34
- parser: {
35
- Description: {
36
- finish() {
37
- this.parent.description = this.text;
38
- }
39
- }
40
- },
41
- finish() {
42
- const obj = {
43
- name: this.attrs.Name
44
- };
45
- if (this.attrs.DataType !== undefined) {
46
- obj.dataType = this.attrs.DataType;
47
- }
48
- if (this.description) {
49
- obj.description = this.description;
50
- }
51
- if (this.attrs.Value !== undefined) {
52
- obj.value = parseInt(this.attrs.Value, 10);
53
- }
54
- if (this.attrs.ValueRank !== undefined) {
55
- obj.valueRank = parseInt(this.attrs.ValueRank, 10);
56
- }
57
- else {
58
- // when not specified valueRank means Scalar and Scalar is -1
59
- obj.valueRank = -1;
60
- }
61
- if (this.attrs.ArrayDimensions !== undefined) {
62
- obj.arrayDimensions = this.attrs.ArrayDimensions.split(",").map((e) => parseInt(e, 10));
63
- }
64
- obj.isOptional = this.attrs.IsOptional === "true" ? true : false;
65
- if (this.attrs.SymbolicName !== undefined) {
66
- obj.symbolicName = this.attrs.SymbolicName;
67
- }
68
- this.parent.array.push(obj);
69
- }
70
- }
71
- }
72
- };
73
- exports.definitionReaderStateParser = {
74
- parser: {
75
- Definition: exports._definitionParser
76
- },
77
- endElement() {
78
- this._pojo = {
79
- name: this.definitionName,
80
- fields: this.definitionFields
81
- };
82
- }
83
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.definitionReaderStateParser = exports._definitionParser = void 0;
4
+ // <Definition Name="SomeName">
5
+ // <Field Name="Running" Value="0" dataType: [ValueRank="1"]>
6
+ // [<Description>text</Description>]
7
+ // <Field>
8
+ // </Definition>
9
+ const node_opcua_assert_1 = require("node-opcua-assert");
10
+ // <Definition Name="SomeName">
11
+ // <Field Name="Running" Value="0" dataType: [ValueRank="1"]>
12
+ // [<Description>text</Description>]
13
+ // <Field>
14
+ // </Definition>
15
+ //
16
+ // Or
17
+ //
18
+ // (IsOptionSet)
19
+ //
20
+ //
21
+ exports._definitionParser = {
22
+ init(name, attrs) {
23
+ (0, node_opcua_assert_1.default)(!this.parent.definitionFields || this.parent.definitionFields.length === 0);
24
+ this.parent.definitionFields = [];
25
+ this.parent.definitionName = attrs.SymbolicName || attrs.Name;
26
+ this.array = this.parent.definitionFields;
27
+ this.isUnion = attrs.IsUnion === "true" ? true : false;
28
+ },
29
+ parser: {
30
+ Field: {
31
+ init() {
32
+ this.description = undefined;
33
+ },
34
+ parser: {
35
+ Description: {
36
+ finish() {
37
+ this.parent.description = this.text;
38
+ }
39
+ }
40
+ },
41
+ finish() {
42
+ const obj = {
43
+ name: this.attrs.Name
44
+ };
45
+ if (this.attrs.DataType !== undefined) {
46
+ obj.dataType = this.attrs.DataType;
47
+ }
48
+ if (this.description) {
49
+ obj.description = this.description;
50
+ }
51
+ if (this.attrs.Value !== undefined) {
52
+ obj.value = parseInt(this.attrs.Value, 10);
53
+ }
54
+ if (this.attrs.ValueRank !== undefined) {
55
+ obj.valueRank = parseInt(this.attrs.ValueRank, 10);
56
+ }
57
+ else {
58
+ // when not specified valueRank means Scalar and Scalar is -1
59
+ obj.valueRank = -1;
60
+ }
61
+ if (this.attrs.ArrayDimensions !== undefined) {
62
+ obj.arrayDimensions = this.attrs.ArrayDimensions.split(",").map((e) => parseInt(e, 10));
63
+ }
64
+ obj.isOptional = this.attrs.IsOptional === "true" ? true : false;
65
+ if (this.attrs.SymbolicName !== undefined) {
66
+ obj.symbolicName = this.attrs.SymbolicName;
67
+ }
68
+ this.parent.array.push(obj);
69
+ }
70
+ }
71
+ }
72
+ };
73
+ exports.definitionReaderStateParser = {
74
+ parser: {
75
+ Definition: exports._definitionParser
76
+ },
77
+ endElement() {
78
+ this._pojo = {
79
+ name: this.definitionName,
80
+ fields: this.definitionFields
81
+ };
82
+ }
83
+ };
84
84
  //# sourceMappingURL=definition_parser.js.map
@@ -1,17 +1,17 @@
1
- import { ReaderState, ReaderStateParserLike } from "./xml2json";
2
- interface Field {
3
- dataType: any;
4
- description?: string;
5
- name: string;
6
- value?: any;
7
- valueRank?: number;
8
- }
9
- export interface Definition {
10
- name: string;
11
- fields: Field[];
12
- }
13
- export interface DefinitionMap {
14
- findDefinition(name: string): Definition;
15
- }
16
- export declare function makeExtensionObjectReader(definitionName: string, definitionMap: DefinitionMap, readerMap: Record<string, ReaderStateParserLike>): ReaderState;
17
- export {};
1
+ import { ReaderState, ReaderStateParserLike } from "./xml2json";
2
+ interface Field {
3
+ dataType: any;
4
+ description?: string;
5
+ name: string;
6
+ value?: any;
7
+ valueRank?: number;
8
+ }
9
+ export interface Definition {
10
+ name: string;
11
+ fields: Field[];
12
+ }
13
+ export interface DefinitionMap {
14
+ findDefinition(name: string): Definition;
15
+ }
16
+ export declare function makeExtensionObjectReader(definitionName: string, definitionMap: DefinitionMap, readerMap: Record<string, ReaderStateParserLike>): ReaderState;
17
+ export {};