node-opcua-data-model 2.55.0 → 2.56.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 (38) hide show
  1. package/dist/_make_flag.d.ts +1 -1
  2. package/dist/_make_flag.js.map +1 -1
  3. package/dist/access_level.js.map +1 -1
  4. package/dist/access_level_ex.js +2 -2
  5. package/dist/access_level_ex.js.map +1 -1
  6. package/dist/access_restrictions.js.map +1 -1
  7. package/dist/attributeIds.js.map +1 -1
  8. package/dist/data_encoding.d.ts +1 -1
  9. package/dist/data_encoding.js +2 -2
  10. package/dist/data_encoding.js.map +1 -1
  11. package/dist/diagnostic_info.d.ts +2 -2
  12. package/dist/diagnostic_info.js.map +1 -1
  13. package/dist/localized_text.d.ts +3 -3
  14. package/dist/localized_text.js.map +1 -1
  15. package/dist/node_class_mask.js.map +1 -1
  16. package/dist/nodeclass.js.map +1 -1
  17. package/dist/permission_flag.js.map +1 -1
  18. package/dist/qualified_name.js +2 -2
  19. package/dist/qualified_name.js.map +1 -1
  20. package/dist/result_mask.js.map +1 -1
  21. package/dist/write_mask.js +1 -1
  22. package/dist/write_mask.js.map +1 -1
  23. package/package.json +9 -7
  24. package/source/BrowseDirection.ts +41 -41
  25. package/source/_make_flag.ts +2 -3
  26. package/source/access_level.ts +18 -13
  27. package/source/access_level_ex.ts +22 -25
  28. package/source/access_restrictions.ts +1 -3
  29. package/source/attributeIds.ts +1 -5
  30. package/source/data_encoding.ts +23 -23
  31. package/source/diagnostic_info.ts +362 -361
  32. package/source/localized_text.ts +189 -188
  33. package/source/node_class_mask.ts +47 -47
  34. package/source/nodeclass.ts +23 -23
  35. package/source/permission_flag.ts +8 -8
  36. package/source/qualified_name.ts +3 -3
  37. package/source/result_mask.ts +35 -35
  38. package/source/write_mask.ts +37 -37
@@ -1,188 +1,189 @@
1
- /**
2
- * @module node-opcua-data-model
3
- */
4
- import { assert } from "node-opcua-assert";
5
- import { decodeByte, decodeString, encodeByte, encodeString, LocaleId, UAString } from "node-opcua-basic-types";
6
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
7
- import {
8
- BaseUAObject,
9
- buildStructuredType,
10
- check_options_correctness_against_schema,
11
- initialize_field,
12
- parameters,
13
- registerSpecialVariantEncoder,
14
- StructuredTypeSchema
15
- } from "node-opcua-factory";
16
-
17
- export function coerceLocalizedText(value?: null | string | LocalizedTextOptions): LocalizedText | null {
18
- if (value === undefined || value === null) {
19
- return null;
20
- }
21
- if (value instanceof LocalizedText) {
22
- return value;
23
- }
24
- return new LocalizedText(value);
25
- }
26
-
27
- // --------------------------------------------------------------------------------------------
28
- // see Part 3 - $8.5 page 63
29
- const schemaLocalizedText = buildStructuredType({
30
- name: "LocalizedText",
31
-
32
- baseType: "BaseUAObject",
33
-
34
- fields: [
35
- {
36
- name: "locale",
37
-
38
- fieldType: "LocaleId",
39
-
40
- defaultValue: null
41
- },
42
- {
43
- name: "text",
44
-
45
- fieldType: "UAString",
46
-
47
- defaultValue: null
48
- }
49
- ]
50
- });
51
- schemaLocalizedText.coerce = coerceLocalizedText;
52
-
53
- export interface LocalizedTextOptions {
54
- locale?: LocaleId;
55
- text?: UAString;
56
- }
57
-
58
- export class LocalizedText extends BaseUAObject {
59
- static get schema(): StructuredTypeSchema {
60
- return schemaLocalizedText;
61
- }
62
-
63
- public get schema(): StructuredTypeSchema {
64
- return schemaLocalizedText;
65
- }
66
-
67
- public static possibleFields: string[] = ["locale", "text"];
68
-
69
- public static coerce(value: any): LocalizedText | null {
70
- return coerceLocalizedText(value);
71
- }
72
-
73
- public locale: LocaleId;
74
- public text: UAString;
75
-
76
- constructor(options?: LocalizedTextOptions | string | null) {
77
- super();
78
- if (options === null) {
79
- this.locale = null;
80
- this.text = null;
81
- return;
82
- }
83
- if (typeof options === "string") {
84
- this.locale = null;
85
- this.text = options;
86
- return;
87
- }
88
- /* istanbul ignore next */
89
- if (parameters.debugSchemaHelper) {
90
- const schema = schemaLocalizedText;
91
- check_options_correctness_against_schema(this, schema, options);
92
- }
93
- this.locale = options?.locale || null;
94
- this.text = options?.text || null;
95
- }
96
-
97
- public toString(): string {
98
- return "locale=" + this.locale + " text=" + this.text;
99
- }
100
-
101
- // OPCUA Part 6 $ 5.2.2.14 : localizedText have a special encoding
102
- public encode(stream: OutputBinaryStream) {
103
- // tslint:disable:no-bitwise
104
- const encodingMask = getLocalizeText_EncodingByte(this);
105
-
106
- encodeByte(encodingMask, stream);
107
- if ((encodingMask & 0x01) === 0x01) {
108
- encodeString(this.locale, stream);
109
- }
110
-
111
- if ((encodingMask & 0x02) === 0x02) {
112
- encodeString(this.text, stream);
113
- }
114
- }
115
-
116
- public decodeDebug(stream: BinaryStream, options: any) {
117
- let cursorBefore;
118
- const tracer = options.tracer;
119
- tracer.trace("start", options.name + "(" + "LocalizedText" + ")", stream.length, stream.length);
120
- cursorBefore = stream.length;
121
-
122
- const encodingMask = decodeByte(stream);
123
- tracer.trace("member", "encodingByte", "0x" + encodingMask.toString(16), cursorBefore, stream.length, "Mask");
124
- cursorBefore = stream.length;
125
-
126
- if ((encodingMask & 0x01) === 0x01) {
127
- this.locale = decodeString(stream);
128
- tracer.trace("member", "locale", this.locale, cursorBefore, stream.length, "locale");
129
- cursorBefore = stream.length;
130
- } else {
131
- this.locale = null;
132
- }
133
- if ((encodingMask & 0x02) === 0x02) {
134
- this.text = decodeString(stream);
135
- tracer.trace("member", "text", this.text, cursorBefore, stream.length, "text");
136
- // cursor_before = stream.length;
137
- } else {
138
- this.text = null;
139
- }
140
- tracer.trace("end", options.name, stream.length, stream.length);
141
- }
142
-
143
- public decode(stream: BinaryStream): void {
144
- const encodingMask = decodeByte(stream);
145
- if ((encodingMask & 0x01) === 0x01) {
146
- this.locale = decodeString(stream);
147
- } else {
148
- this.locale = null;
149
- }
150
- if ((encodingMask & 0x02) === 0x02) {
151
- this.text = decodeString(stream);
152
- } else {
153
- this.text = null;
154
- }
155
- }
156
- }
157
-
158
- // not an extension object registerClassDefinition("LocalizedText", LocalizedText);
159
- registerSpecialVariantEncoder(LocalizedText);
160
-
161
- export type LocalizedTextLike = LocalizedTextOptions | string;
162
-
163
- function getLocalizeText_EncodingByte(localizedText: LocalizedText): number {
164
- let encodingMask = 0;
165
- if (localizedText.locale) {
166
- encodingMask |= 0x01;
167
- }
168
- if (localizedText.text) {
169
- encodingMask |= 0x02;
170
- }
171
- return encodingMask;
172
- }
173
-
174
- const emptyLocalizedText = new LocalizedText({});
175
-
176
- export function encodeLocalizedText(value: LocalizedText, stream: OutputBinaryStream): void {
177
- if (value) {
178
- value.encode(stream);
179
- } else {
180
- emptyLocalizedText.encode(stream);
181
- }
182
- }
183
-
184
- export function decodeLocalizedText(stream: BinaryStream, value?: LocalizedText): LocalizedText {
185
- value = value || new LocalizedText(null);
186
- value.decode(stream);
187
- return value;
188
- }
1
+ /**
2
+ * @module node-opcua-data-model
3
+ */
4
+ import { assert } from "node-opcua-assert";
5
+ import { decodeByte, decodeString, encodeByte, encodeString, LocaleId, UAString } from "node-opcua-basic-types";
6
+ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
7
+ import {
8
+ BaseUAObject,
9
+ buildStructuredType,
10
+ check_options_correctness_against_schema,
11
+ DecodeDebugOptions,
12
+ initialize_field,
13
+ parameters,
14
+ registerSpecialVariantEncoder,
15
+ StructuredTypeSchema
16
+ } from "node-opcua-factory";
17
+
18
+ export function coerceLocalizedText(value?: null | string | LocalizedTextOptions): LocalizedText | null {
19
+ if (value === undefined || value === null) {
20
+ return null;
21
+ }
22
+ if (value instanceof LocalizedText) {
23
+ return value;
24
+ }
25
+ return new LocalizedText(value);
26
+ }
27
+
28
+ // --------------------------------------------------------------------------------------------
29
+ // see Part 3 - $8.5 page 63
30
+ const schemaLocalizedText = buildStructuredType({
31
+ name: "LocalizedText",
32
+
33
+ baseType: "BaseUAObject",
34
+
35
+ fields: [
36
+ {
37
+ name: "locale",
38
+
39
+ fieldType: "LocaleId",
40
+
41
+ defaultValue: null
42
+ },
43
+ {
44
+ name: "text",
45
+
46
+ fieldType: "UAString",
47
+
48
+ defaultValue: null
49
+ }
50
+ ]
51
+ });
52
+ schemaLocalizedText.coerce = coerceLocalizedText;
53
+
54
+ export interface LocalizedTextOptions {
55
+ locale?: LocaleId;
56
+ text?: UAString;
57
+ }
58
+
59
+ export class LocalizedText extends BaseUAObject {
60
+ static get schema(): StructuredTypeSchema {
61
+ return schemaLocalizedText;
62
+ }
63
+
64
+ public get schema(): StructuredTypeSchema {
65
+ return schemaLocalizedText;
66
+ }
67
+
68
+ public static possibleFields: string[] = ["locale", "text"];
69
+
70
+ public static coerce(value?: null | string | LocalizedTextOptions): LocalizedText | null {
71
+ return coerceLocalizedText(value);
72
+ }
73
+
74
+ public locale: LocaleId;
75
+ public text: UAString;
76
+
77
+ constructor(options?: LocalizedTextOptions | string | null) {
78
+ super();
79
+ if (options === null) {
80
+ this.locale = null;
81
+ this.text = null;
82
+ return;
83
+ }
84
+ if (typeof options === "string") {
85
+ this.locale = null;
86
+ this.text = options;
87
+ return;
88
+ }
89
+ /* istanbul ignore next */
90
+ if (parameters.debugSchemaHelper) {
91
+ const schema = schemaLocalizedText;
92
+ check_options_correctness_against_schema(this, schema, options);
93
+ }
94
+ this.locale = options?.locale || null;
95
+ this.text = options?.text || null;
96
+ }
97
+
98
+ public toString(): string {
99
+ return "locale=" + this.locale + " text=" + this.text;
100
+ }
101
+
102
+ // OPCUA Part 6 $ 5.2.2.14 : localizedText have a special encoding
103
+ public encode(stream: OutputBinaryStream): void {
104
+ // tslint:disable:no-bitwise
105
+ const encodingMask = getLocalizeText_EncodingByte(this);
106
+
107
+ encodeByte(encodingMask, stream);
108
+ if ((encodingMask & 0x01) === 0x01) {
109
+ encodeString(this.locale, stream);
110
+ }
111
+
112
+ if ((encodingMask & 0x02) === 0x02) {
113
+ encodeString(this.text, stream);
114
+ }
115
+ }
116
+
117
+ public decodeDebug(stream: BinaryStream, options: DecodeDebugOptions): void {
118
+ let cursorBefore;
119
+ const tracer = options.tracer;
120
+ tracer.trace("start", options.name + "(" + "LocalizedText" + ")", stream.length, stream.length);
121
+ cursorBefore = stream.length;
122
+
123
+ const encodingMask = decodeByte(stream);
124
+ tracer.trace("member", "encodingByte", "0x" + encodingMask.toString(16), cursorBefore, stream.length, "Mask");
125
+ cursorBefore = stream.length;
126
+
127
+ if ((encodingMask & 0x01) === 0x01) {
128
+ this.locale = decodeString(stream);
129
+ tracer.trace("member", "locale", this.locale, cursorBefore, stream.length, "locale");
130
+ cursorBefore = stream.length;
131
+ } else {
132
+ this.locale = null;
133
+ }
134
+ if ((encodingMask & 0x02) === 0x02) {
135
+ this.text = decodeString(stream);
136
+ tracer.trace("member", "text", this.text, cursorBefore, stream.length, "text");
137
+ // cursor_before = stream.length;
138
+ } else {
139
+ this.text = null;
140
+ }
141
+ tracer.trace("end", options.name, stream.length, stream.length);
142
+ }
143
+
144
+ public decode(stream: BinaryStream): void {
145
+ const encodingMask = decodeByte(stream);
146
+ if ((encodingMask & 0x01) === 0x01) {
147
+ this.locale = decodeString(stream);
148
+ } else {
149
+ this.locale = null;
150
+ }
151
+ if ((encodingMask & 0x02) === 0x02) {
152
+ this.text = decodeString(stream);
153
+ } else {
154
+ this.text = null;
155
+ }
156
+ }
157
+ }
158
+
159
+ // not an extension object registerClassDefinition("LocalizedText", LocalizedText);
160
+ registerSpecialVariantEncoder(LocalizedText);
161
+
162
+ export type LocalizedTextLike = LocalizedTextOptions | string;
163
+
164
+ function getLocalizeText_EncodingByte(localizedText: LocalizedText): number {
165
+ let encodingMask = 0;
166
+ if (localizedText.locale) {
167
+ encodingMask |= 0x01;
168
+ }
169
+ if (localizedText.text) {
170
+ encodingMask |= 0x02;
171
+ }
172
+ return encodingMask;
173
+ }
174
+
175
+ const emptyLocalizedText = new LocalizedText({});
176
+
177
+ export function encodeLocalizedText(value: LocalizedText, stream: OutputBinaryStream): void {
178
+ if (value) {
179
+ value.encode(stream);
180
+ } else {
181
+ emptyLocalizedText.encode(stream);
182
+ }
183
+ }
184
+
185
+ export function decodeLocalizedText(stream: BinaryStream, value?: LocalizedText): LocalizedText {
186
+ value = value || new LocalizedText(null);
187
+ value.decode(stream);
188
+ return value;
189
+ }
@@ -1,47 +1,47 @@
1
- /**
2
- * @module node-opcua-data-model
3
- */
4
- // tslint:disable:no-bitwise
5
-
6
- // Specifies the NodeClasses of the TargetNodes. Only TargetNodes with the
7
- // selected NodeClasses are returned. The NodeClasses are assigned the
8
- // following bits:
9
- // If set to zero, then all NodeClasses are returned.
10
- // @example
11
- // var mask = NodeClassMask.get("Object | ObjectType");
12
- // mask.value.should.eql(1 + (1<<3));
13
-
14
- export enum NodeClassMask {
15
- Object= (1 << 0),
16
- Variable = (1 << 1),
17
- Method= (1 << 2),
18
- ObjectType= (1 << 3),
19
- VariableType= (1 << 4),
20
- ReferenceType= (1 << 5),
21
- DataType= (1 << 6),
22
- View= (1 << 7)
23
- }
24
-
25
- interface Enum {
26
- [id: string]: number;
27
- }
28
-
29
- function makeFlagFromString<Type>(type: Enum, str: string): Type {
30
- const flags = str.split(" | ");
31
- let result: any = 0;
32
- for (const flag of flags) {
33
- result |= type[flag];
34
- }
35
- return result as Type;
36
- }
37
-
38
- // @example
39
- // makeNodeClassMask("Method | Object").should.eql(5);
40
- export function makeNodeClassMask(str: string): NodeClassMask {
41
- const classMask = makeFlagFromString<NodeClassMask>(NodeClassMask as any, str);
42
- /* istanbul ignore next */
43
- if (!classMask) {
44
- throw new Error(" cannot find class mask for " + str);
45
- }
46
- return classMask;
47
- }
1
+ /**
2
+ * @module node-opcua-data-model
3
+ */
4
+ // tslint:disable:no-bitwise
5
+
6
+ // Specifies the NodeClasses of the TargetNodes. Only TargetNodes with the
7
+ // selected NodeClasses are returned. The NodeClasses are assigned the
8
+ // following bits:
9
+ // If set to zero, then all NodeClasses are returned.
10
+ // @example
11
+ // var mask = NodeClassMask.get("Object | ObjectType");
12
+ // mask.value.should.eql(1 + (1<<3));
13
+
14
+ export enum NodeClassMask {
15
+ Object = 1 << 0,
16
+ Variable = 1 << 1,
17
+ Method = 1 << 2,
18
+ ObjectType = 1 << 3,
19
+ VariableType = 1 << 4,
20
+ ReferenceType = 1 << 5,
21
+ DataType = 1 << 6,
22
+ View = 1 << 7
23
+ }
24
+
25
+ interface Enum {
26
+ [id: string]: number;
27
+ }
28
+
29
+ function makeFlagFromString<Type>(type: Enum, str: string): Type {
30
+ const flags = str.split(" | ");
31
+ let result: any = 0;
32
+ for (const flag of flags) {
33
+ result |= type[flag];
34
+ }
35
+ return result as Type;
36
+ }
37
+
38
+ // @example
39
+ // makeNodeClassMask("Method | Object").should.eql(5);
40
+ export function makeNodeClassMask(str: string): NodeClassMask {
41
+ const classMask = makeFlagFromString<NodeClassMask>(NodeClassMask as any, str);
42
+ /* istanbul ignore next */
43
+ if (!classMask) {
44
+ throw new Error(" cannot find class mask for " + str);
45
+ }
46
+ return classMask;
47
+ }
@@ -1,23 +1,23 @@
1
- /**
2
- * @module node-opcua-data-model
3
- */
4
- import { registerEnumeration } from "node-opcua-factory";
5
-
6
- export enum NodeClass {
7
- Unspecified= 0, // No classes are selected.
8
- Object= 1, // The node is an object.
9
- Variable= 2, // The node is a variable.
10
- Method= 4, // The node is a method.
11
- ObjectType= 8, // The node is an object type.
12
- VariableType= 16, // The node is an variable type.
13
- ReferenceType= 32, // The node is a reference type.
14
- DataType= 64, // The node is a data type.
15
- View= 128 // The node is a view.
16
- }
17
- export const schemaEnumNodeClass = {
18
- name: "NodeClass",
19
-
20
- documentation: "A mask specifying the class of the node.",
21
- enumValues: NodeClass
22
- };
23
- registerEnumeration(schemaEnumNodeClass);
1
+ /**
2
+ * @module node-opcua-data-model
3
+ */
4
+ import { registerEnumeration } from "node-opcua-factory";
5
+
6
+ export enum NodeClass {
7
+ Unspecified = 0, // No classes are selected.
8
+ Object = 1, // The node is an object.
9
+ Variable = 2, // The node is a variable.
10
+ Method = 4, // The node is a method.
11
+ ObjectType = 8, // The node is an object type.
12
+ VariableType = 16, // The node is an variable type.
13
+ ReferenceType = 32, // The node is a reference type.
14
+ DataType = 64, // The node is a data type.
15
+ View = 128 // The node is a view.
16
+ }
17
+ export const schemaEnumNodeClass = {
18
+ name: "NodeClass",
19
+
20
+ documentation: "A mask specifying the class of the node.",
21
+ enumValues: NodeClass
22
+ };
23
+ registerEnumeration(schemaEnumNodeClass);
@@ -25,14 +25,14 @@ export enum PermissionFlag {
25
25
  ReadRolePermissions = 2,
26
26
  /**
27
27
  * The Client is allowed to write to Attributes other than the Value,
28
- * Historizing or RolePermissions Attribute if the WriteMask indicates that
28
+ * Historizing or RolePermissions Attribute if the WriteMask indicates that
29
29
  * the Attribute is writeable.
30
30
  * This bit affects the value of a UserWriteMask Attribute.
31
31
  * This Permission is valid for all NodeClasses.
32
32
  */
33
33
  WriteAttribute = 4,
34
34
  /**
35
- * The Client is allowed to write to the RolePermissions Attribute if the WriteMask
35
+ * The Client is allowed to write to the RolePermissions Attribute if the WriteMask
36
36
  * indicates that the Attribute is writeable.
37
37
  * This bit affects the value of the UserWriteMask Attribute.
38
38
  * This Permission is valid for all NodeClasses.
@@ -81,14 +81,14 @@ export enum PermissionFlag {
81
81
  */
82
82
  DeleteHistory = 1024,
83
83
  /**
84
- * A Client only receives an Event if this bit is set on the Node identified
84
+ * A Client only receives an Event if this bit is set on the Node identified
85
85
  * by the EventTypeId field and on the Node identified by the SourceNode field.
86
86
  * This Permission is only valid for EventType Nodes or SourceNodes.
87
87
  */
88
88
  ReceiveEvents = 2048,
89
89
  /**
90
- * The Client is allowed to call the Method if this bit is set on the Object or
91
- * ObjectType Node passed in the Call request and the Method Instance associated
90
+ * The Client is allowed to call the Method if this bit is set on the Object or
91
+ * ObjectType Node passed in the Call request and the Method Instance associated
92
92
  * with that Object or ObjectType.
93
93
  * This bit affects the UserExecutable Attribute when set on Method Node.
94
94
  * This Permission is only valid for Objects, ObjectType or Methods.
@@ -101,7 +101,7 @@ export enum PermissionFlag {
101
101
  AddReference = 8192,
102
102
  /**
103
103
  * The Client is allowed to remove references from the Node.
104
- * This Permission is valid for all NodeClasses.
104
+ * This Permission is valid for all NodeClasses.
105
105
  */
106
106
  RemoveReference = 16384,
107
107
  /**
@@ -117,7 +117,8 @@ export enum PermissionFlag {
117
117
  AddNode = 65536
118
118
  }
119
119
 
120
- export const allPermissions = PermissionFlag.Browse |
120
+ export const allPermissions =
121
+ PermissionFlag.Browse |
121
122
  PermissionFlag.Browse |
122
123
  PermissionFlag.ReadRolePermissions |
123
124
  PermissionFlag.WriteAttribute |
@@ -146,7 +147,6 @@ export function makePermissionFlag(str: string | number | null): number {
146
147
  }
147
148
 
148
149
  export function permissionFlagToString(permissionFlag: PermissionFlag): string {
149
-
150
150
  const retVal = [];
151
151
  for (const [key, value] of Object.entries(PermissionFlag)) {
152
152
  const numKey = parseInt(key, 10);
@@ -98,7 +98,7 @@ export class QualifiedName extends BaseUAObject {
98
98
  return this.name || "<null>";
99
99
  }
100
100
 
101
- public isEmpty() {
101
+ public isEmpty(): boolean {
102
102
  return !this.name || this.name.length === 0;
103
103
  }
104
104
  }
@@ -154,8 +154,8 @@ export function coerceQualifiedName(value: null | QualifiedNameLike): QualifiedN
154
154
  } else if (typeof value === "string") {
155
155
  return stringToQualifiedName(value);
156
156
  } else {
157
- assert(value.hasOwnProperty("namespaceIndex"));
158
- assert(value.hasOwnProperty("name"));
157
+ assert(Object.prototype.hasOwnProperty.call(value, "namespaceIndex"));
158
+ assert(Object.prototype.hasOwnProperty.call(value, "name"));
159
159
  return new QualifiedName(value);
160
160
  }
161
161
  }