node-opcua-service-filter 2.56.2 → 2.61.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.
package/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014-2021 Etienne Rossignon
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2021 Etienne Rossignon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-service-filter",
3
- "version": "2.56.2",
3
+ "version": "2.61.0",
4
4
  "description": "pure nodejs OPCUA SDK - module -service-filter",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -11,21 +11,21 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "node-opcua-assert": "2.55.0",
14
- "node-opcua-basic-types": "2.56.0",
14
+ "node-opcua-basic-types": "2.61.0",
15
15
  "node-opcua-binary-stream": "2.55.0",
16
16
  "node-opcua-constants": "2.52.0",
17
- "node-opcua-data-model": "2.56.0",
18
- "node-opcua-debug": "2.55.0",
19
- "node-opcua-factory": "2.56.0",
20
- "node-opcua-nodeid": "2.55.0",
21
- "node-opcua-numeric-range": "2.56.0",
22
- "node-opcua-service-translate-browse-path": "2.56.2",
17
+ "node-opcua-data-model": "2.61.0",
18
+ "node-opcua-debug": "2.61.0",
19
+ "node-opcua-factory": "2.61.0",
20
+ "node-opcua-nodeid": "2.61.0",
21
+ "node-opcua-numeric-range": "2.61.0",
22
+ "node-opcua-service-translate-browse-path": "2.61.0",
23
23
  "node-opcua-status-code": "2.56.0",
24
- "node-opcua-types": "2.56.2",
25
- "node-opcua-variant": "2.56.0"
24
+ "node-opcua-types": "2.61.0",
25
+ "node-opcua-variant": "2.61.0"
26
26
  },
27
27
  "devDependencies": {
28
- "node-opcua-service-secure-channel": "2.56.2",
28
+ "node-opcua-service-secure-channel": "2.61.0",
29
29
  "should": "^13.2.3"
30
30
  },
31
31
  "author": "Etienne Rossignon",
@@ -43,5 +43,5 @@
43
43
  "internet of things"
44
44
  ],
45
45
  "homepage": "http://node-opcua.github.io/",
46
- "gitHead": "45dbf2f65d96a91fae6e884bb5006af4249cf1fa"
46
+ "gitHead": "dd8776f047686ca791989f27e11ee48bfd8b61b7"
47
47
  }
package/source/imports.ts CHANGED
@@ -1,33 +1,33 @@
1
- /**
2
- * @module node-opcua-service-filter
3
- */
4
- export {
5
-
6
- FilterOperator,
7
-
8
- AttributeOperand,
9
- ElementOperand,
10
- FilterOperand,
11
- LiteralOperand,
12
- SimpleAttributeOperand,
13
-
14
- MonitoringFilter,
15
-
16
- ContentFilterElement,
17
- ContentFilter,
18
- EventFilter,
19
- DataChangeFilter,
20
-
21
- AttributeOperandOptions,
22
- ElementOperandOptions,
23
- FilterOperandOptions,
24
- LiteralOperandOptions,
25
- SimpleAttributeOperandOptions,
26
-
27
- MonitoringFilterOptions,
28
-
29
- ContentFilterElementOptions,
30
- ContentFilterOptions,
31
- EventFilterOptions
32
-
33
- } from "node-opcua-types";
1
+ /**
2
+ * @module node-opcua-service-filter
3
+ */
4
+ export {
5
+
6
+ FilterOperator,
7
+
8
+ AttributeOperand,
9
+ ElementOperand,
10
+ FilterOperand,
11
+ LiteralOperand,
12
+ SimpleAttributeOperand,
13
+
14
+ MonitoringFilter,
15
+
16
+ ContentFilterElement,
17
+ ContentFilter,
18
+ EventFilter,
19
+ DataChangeFilter,
20
+
21
+ AttributeOperandOptions,
22
+ ElementOperandOptions,
23
+ FilterOperandOptions,
24
+ LiteralOperandOptions,
25
+ SimpleAttributeOperandOptions,
26
+
27
+ MonitoringFilterOptions,
28
+
29
+ ContentFilterElementOptions,
30
+ ContentFilterOptions,
31
+ EventFilterOptions
32
+
33
+ } from "node-opcua-types";
package/source/index.ts CHANGED
@@ -1,42 +1,42 @@
1
- /**
2
- * @module node-opcua-service-filter
3
- */
4
- export * from "./imports";
5
- export * from "./tools_event_filter";
6
-
7
- // The SimpleAttributeOperand is a simplified form of the AttributeOperand and all of the rules that
8
- // apply to the AttributeOperand also apply to the SimpleAttributeOperand. The examples provided in
9
- // B.1 only use AttributeOperand, however, the AttributeOperand can be replaced by a
10
- // SimpleAttributeOperand whenever all ReferenceTypes in the RelativePath are subtypes of
11
- // HierarchicalReferences and the targets are Object or Variable Nodes and an Alias is not required
12
-
13
- // typeDefinitionId
14
- // This parameter restricts the operand to instances of the TypeDefinitionNode or
15
- // one of its subtypes.
16
- // { name: "typeDefinitionId", fieldType:"NodeId",documentation:"NodeId of a TypeDefinitionNode."},
17
-
18
- // browsePath
19
- // A relative path to a Node.
20
- // This parameter specifies a relative path using a list of BrowseNames instead of
21
- // the RelativePath structure used in the AttributeOperand. The list of
22
- // BrowseNames is equivalent to a RelativePath that specifies forward references
23
- // which are subtypes of the HierarchicalReferences ReferenceType.
24
- // All Nodes followed by the browsePath shall be of the NodeClass Object or
25
- // Variable.
26
- // If this list is empty the Node is the instance of the TypeDefinition.
27
- // { name: "browsePath", isArray:true, fieldType:"QualifiedName"},
28
-
29
- // Id of the Attribute. The IntegerId is defined in 7.13.
30
- // The Value Attribute shall be supported by all Servers. The support of other
31
- // Attributes depends on requirements set in Profiles or other parts of this
32
- // specification.
33
- // { name: "attributeId", fieldType:"IntegerId"},
34
-
35
- // This parameter is used to identify a single element of an array, or a single range
36
- // of indexes for an array. The first element is identified by index 0 (zero).
37
- // This parameter is ignored if the selected Node is not a Variable or the Value of a
38
- // Variable is not an array.
39
- // The parameter is null if not specified.
40
- // All values in the array are used if this parameter is not specified.
41
- // The NumericRange type is defined in 7.21.
42
- // { name: "indexRange", fieldType:"NumericRange"}
1
+ /**
2
+ * @module node-opcua-service-filter
3
+ */
4
+ export * from "./imports";
5
+ export * from "./tools_event_filter";
6
+
7
+ // The SimpleAttributeOperand is a simplified form of the AttributeOperand and all of the rules that
8
+ // apply to the AttributeOperand also apply to the SimpleAttributeOperand. The examples provided in
9
+ // B.1 only use AttributeOperand, however, the AttributeOperand can be replaced by a
10
+ // SimpleAttributeOperand whenever all ReferenceTypes in the RelativePath are subtypes of
11
+ // HierarchicalReferences and the targets are Object or Variable Nodes and an Alias is not required
12
+
13
+ // typeDefinitionId
14
+ // This parameter restricts the operand to instances of the TypeDefinitionNode or
15
+ // one of its subtypes.
16
+ // { name: "typeDefinitionId", fieldType:"NodeId",documentation:"NodeId of a TypeDefinitionNode."},
17
+
18
+ // browsePath
19
+ // A relative path to a Node.
20
+ // This parameter specifies a relative path using a list of BrowseNames instead of
21
+ // the RelativePath structure used in the AttributeOperand. The list of
22
+ // BrowseNames is equivalent to a RelativePath that specifies forward references
23
+ // which are subtypes of the HierarchicalReferences ReferenceType.
24
+ // All Nodes followed by the browsePath shall be of the NodeClass Object or
25
+ // Variable.
26
+ // If this list is empty the Node is the instance of the TypeDefinition.
27
+ // { name: "browsePath", isArray:true, fieldType:"QualifiedName"},
28
+
29
+ // Id of the Attribute. The IntegerId is defined in 7.13.
30
+ // The Value Attribute shall be supported by all Servers. The support of other
31
+ // Attributes depends on requirements set in Profiles or other parts of this
32
+ // specification.
33
+ // { name: "attributeId", fieldType:"IntegerId"},
34
+
35
+ // This parameter is used to identify a single element of an array, or a single range
36
+ // of indexes for an array. The first element is identified by index 0 (zero).
37
+ // This parameter is ignored if the selected Node is not a Variable or the Value of a
38
+ // Variable is not an array.
39
+ // The parameter is null if not specified.
40
+ // All values in the array are used if this parameter is not specified.
41
+ // The NumericRange type is defined in 7.21.
42
+ // { name: "indexRange", fieldType:"NumericRange"}
@@ -1,169 +1,169 @@
1
- /**
2
- * @module node-opcua-service-filter
3
- */
4
- // tslint:disable:object-literal-shorthand
5
- // tslint:disable:only-arrow-functions
6
- // tslint:disable:max-line-length
7
-
8
- import { assert } from "node-opcua-assert";
9
- import { ObjectTypeIds } from "node-opcua-constants";
10
- import { AttributeIds, stringToQualifiedName } from "node-opcua-data-model";
11
- import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
12
- import { makeNodeId, NodeId, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
13
- import { DataType, Variant } from "node-opcua-variant";
14
-
15
- import { EventFilter, SimpleAttributeOperand } from "./imports";
16
-
17
- const debugLog = make_debugLog(__filename);
18
- const doDebug = checkDebugFlag(__filename);
19
-
20
- /**
21
- * helper to construct event filters:
22
- * construct a simple event filter
23
- *
24
- *
25
- * @example
26
- *
27
- * constructEventFilter(["SourceName","Message","ReceiveTime"]);
28
- *
29
- * constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
30
- * constructEventFilter(["SourceName","2:MyData" ]);
31
- *
32
- * constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
33
- * constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
34
- *
35
- */
36
- export function constructEventFilter(arrayOfNames: string[] | string, conditionTypes?: NodeId[] | NodeId): EventFilter {
37
- if (!Array.isArray(arrayOfNames)) {
38
- return constructEventFilter([arrayOfNames], conditionTypes);
39
- }
40
- if (conditionTypes && !Array.isArray(conditionTypes)) {
41
- return constructEventFilter(arrayOfNames, [conditionTypes]);
42
- }
43
- // istanbul ignore next
44
- if (!(arrayOfNames instanceof Array)) {
45
- throw new Error("internal error");
46
- }
47
- // replace "string" element in the form A.B.C into [ "A","B","C"]
48
- const arrayOfNames2 = arrayOfNames.map((path) => {
49
- if (typeof path !== "string") {
50
- return path;
51
- }
52
- return path.split(".");
53
- });
54
-
55
- const arrayOfNames3 = arrayOfNames2.map((path) => {
56
- if (Array.isArray(path)) {
57
- return path.map(stringToQualifiedName);
58
- }
59
- return path;
60
- });
61
- // replace "string" elements in arrayOfName with QualifiedName in namespace 0
62
- const arrayOfNames4 = arrayOfNames3.map((s) => {
63
- return typeof s === "string" ? stringToQualifiedName(s) : s;
64
- });
65
-
66
- // construct browse paths array
67
- const browsePaths = arrayOfNames4.map((s) => {
68
- return Array.isArray(s) ? s : [s];
69
- });
70
-
71
- // Part 4 page 127:
72
- // In some cases the same BrowsePath will apply to multiple EventTypes. If the Client specifies the BaseEventType
73
- // in the SimpleAttributeOperand then the Server shall evaluate the BrowsePath without considering the Type.
74
-
75
- // [..]
76
- // The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only
77
- // required to support the Value Attribute for Variable Nodes and the NodeId Attribute for Object Nodes.
78
- // That said, profiles defined in Part 7 may make support for additional Attributes mandatory.
79
- let selectClauses = browsePaths.map((browsePath) => {
80
- return new SimpleAttributeOperand({
81
- attributeId: AttributeIds.Value,
82
- browsePath,
83
- indexRange: undefined, // NumericRange
84
- typeDefinitionId: makeNodeId(ObjectTypeIds.BaseEventType) // i=2041
85
- });
86
- });
87
-
88
- if (conditionTypes && conditionTypes instanceof Array) {
89
- const extraSelectClauses = conditionTypes.map((nodeId) => {
90
- return new SimpleAttributeOperand({
91
- attributeId: AttributeIds.NodeId,
92
- browsePath: undefined,
93
- indexRange: undefined, // NumericRange
94
- typeDefinitionId: nodeId // conditionType for instance
95
- });
96
- });
97
- selectClauses = selectClauses.concat(extraSelectClauses);
98
- }
99
-
100
- const filter = new EventFilter({
101
- selectClauses: selectClauses,
102
-
103
- whereClause: {
104
- // ContentFilter
105
- elements: [
106
- // ContentFilterElement
107
- // {
108
- // filterOperator: FilterOperator.IsNull,
109
- // filterOperands: [ //
110
- // new ElementOperand({
111
- // index: 123
112
- // }),
113
- // new AttributeOperand({
114
- // nodeId: "i=10",
115
- // alias: "someText",
116
- // browsePath: { //RelativePath
117
- //
118
- // },
119
- // attributeId: AttributeIds.Value
120
- // })
121
- // ]
122
- // }
123
- ]
124
- }
125
- });
126
- return filter;
127
- }
128
-
129
- /**
130
- * @class SimpleAttributeOperand
131
- * @method toPath
132
- * @return {String}
133
- *
134
- * @example:
135
- *
136
- *
137
- */
138
- function simpleAttributeOperandToPath(self: SimpleAttributeOperand): string {
139
- if (!self.browsePath) {
140
- return "";
141
- }
142
- return self.browsePath
143
- .map((a) => {
144
- return a.name;
145
- })
146
- .join("/");
147
- }
148
-
149
- /**
150
- * @class SimpleAttributeOperand
151
- * @method toShortString
152
- * @return {String}
153
- *
154
- * @example:
155
- *
156
- *
157
- */
158
- export function simpleAttributeOperandToShortString(
159
- self: SimpleAttributeOperand,
160
- addressSpace: any // Address Space
161
- ): string {
162
- let str = "";
163
- if (addressSpace) {
164
- const n = addressSpace.findNode(self.typeDefinitionId)!;
165
- str += n.BrowseName.toString();
166
- }
167
- str += "[" + self.typeDefinitionId.toString() + "]" + simpleAttributeOperandToPath(self);
168
- return str;
169
- }
1
+ /**
2
+ * @module node-opcua-service-filter
3
+ */
4
+ // tslint:disable:object-literal-shorthand
5
+ // tslint:disable:only-arrow-functions
6
+ // tslint:disable:max-line-length
7
+
8
+ import { assert } from "node-opcua-assert";
9
+ import { ObjectTypeIds } from "node-opcua-constants";
10
+ import { AttributeIds, stringToQualifiedName } from "node-opcua-data-model";
11
+ import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
12
+ import { makeNodeId, NodeId, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
13
+ import { DataType, Variant } from "node-opcua-variant";
14
+
15
+ import { EventFilter, SimpleAttributeOperand } from "./imports";
16
+
17
+ const debugLog = make_debugLog(__filename);
18
+ const doDebug = checkDebugFlag(__filename);
19
+
20
+ /**
21
+ * helper to construct event filters:
22
+ * construct a simple event filter
23
+ *
24
+ *
25
+ * @example
26
+ *
27
+ * constructEventFilter(["SourceName","Message","ReceiveTime"]);
28
+ *
29
+ * constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
30
+ * constructEventFilter(["SourceName","2:MyData" ]);
31
+ *
32
+ * constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
33
+ * constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
34
+ *
35
+ */
36
+ export function constructEventFilter(arrayOfNames: string[] | string, conditionTypes?: NodeId[] | NodeId): EventFilter {
37
+ if (!Array.isArray(arrayOfNames)) {
38
+ return constructEventFilter([arrayOfNames], conditionTypes);
39
+ }
40
+ if (conditionTypes && !Array.isArray(conditionTypes)) {
41
+ return constructEventFilter(arrayOfNames, [conditionTypes]);
42
+ }
43
+ // istanbul ignore next
44
+ if (!(arrayOfNames instanceof Array)) {
45
+ throw new Error("internal error");
46
+ }
47
+ // replace "string" element in the form A.B.C into [ "A","B","C"]
48
+ const arrayOfNames2 = arrayOfNames.map((path) => {
49
+ if (typeof path !== "string") {
50
+ return path;
51
+ }
52
+ return path.split(".");
53
+ });
54
+
55
+ const arrayOfNames3 = arrayOfNames2.map((path) => {
56
+ if (Array.isArray(path)) {
57
+ return path.map(stringToQualifiedName);
58
+ }
59
+ return path;
60
+ });
61
+ // replace "string" elements in arrayOfName with QualifiedName in namespace 0
62
+ const arrayOfNames4 = arrayOfNames3.map((s) => {
63
+ return typeof s === "string" ? stringToQualifiedName(s) : s;
64
+ });
65
+
66
+ // construct browse paths array
67
+ const browsePaths = arrayOfNames4.map((s) => {
68
+ return Array.isArray(s) ? s : [s];
69
+ });
70
+
71
+ // Part 4 page 127:
72
+ // In some cases the same BrowsePath will apply to multiple EventTypes. If the Client specifies the BaseEventType
73
+ // in the SimpleAttributeOperand then the Server shall evaluate the BrowsePath without considering the Type.
74
+
75
+ // [..]
76
+ // The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only
77
+ // required to support the Value Attribute for Variable Nodes and the NodeId Attribute for Object Nodes.
78
+ // That said, profiles defined in Part 7 may make support for additional Attributes mandatory.
79
+ let selectClauses = browsePaths.map((browsePath) => {
80
+ return new SimpleAttributeOperand({
81
+ attributeId: AttributeIds.Value,
82
+ browsePath,
83
+ indexRange: undefined, // NumericRange
84
+ typeDefinitionId: makeNodeId(ObjectTypeIds.BaseEventType) // i=2041
85
+ });
86
+ });
87
+
88
+ if (conditionTypes && conditionTypes instanceof Array) {
89
+ const extraSelectClauses = conditionTypes.map((nodeId) => {
90
+ return new SimpleAttributeOperand({
91
+ attributeId: AttributeIds.NodeId,
92
+ browsePath: undefined,
93
+ indexRange: undefined, // NumericRange
94
+ typeDefinitionId: nodeId // conditionType for instance
95
+ });
96
+ });
97
+ selectClauses = selectClauses.concat(extraSelectClauses);
98
+ }
99
+
100
+ const filter = new EventFilter({
101
+ selectClauses: selectClauses,
102
+
103
+ whereClause: {
104
+ // ContentFilter
105
+ elements: [
106
+ // ContentFilterElement
107
+ // {
108
+ // filterOperator: FilterOperator.IsNull,
109
+ // filterOperands: [ //
110
+ // new ElementOperand({
111
+ // index: 123
112
+ // }),
113
+ // new AttributeOperand({
114
+ // nodeId: "i=10",
115
+ // alias: "someText",
116
+ // browsePath: { //RelativePath
117
+ //
118
+ // },
119
+ // attributeId: AttributeIds.Value
120
+ // })
121
+ // ]
122
+ // }
123
+ ]
124
+ }
125
+ });
126
+ return filter;
127
+ }
128
+
129
+ /**
130
+ * @class SimpleAttributeOperand
131
+ * @method toPath
132
+ * @return {String}
133
+ *
134
+ * @example:
135
+ *
136
+ *
137
+ */
138
+ function simpleAttributeOperandToPath(self: SimpleAttributeOperand): string {
139
+ if (!self.browsePath) {
140
+ return "";
141
+ }
142
+ return self.browsePath
143
+ .map((a) => {
144
+ return a.name;
145
+ })
146
+ .join("/");
147
+ }
148
+
149
+ /**
150
+ * @class SimpleAttributeOperand
151
+ * @method toShortString
152
+ * @return {String}
153
+ *
154
+ * @example:
155
+ *
156
+ *
157
+ */
158
+ export function simpleAttributeOperandToShortString(
159
+ self: SimpleAttributeOperand,
160
+ addressSpace: any // Address Space
161
+ ): string {
162
+ let str = "";
163
+ if (addressSpace) {
164
+ const n = addressSpace.findNode(self.typeDefinitionId)!;
165
+ str += n.BrowseName.toString();
166
+ }
167
+ str += "[" + self.typeDefinitionId.toString() + "]" + simpleAttributeOperandToPath(self);
168
+ return str;
169
+ }