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