node-opcua-service-filter 2.107.0 → 2.109.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/dist/resolve_operand.js +3 -1
- package/dist/resolve_operand.js.map +1 -1
- package/dist/tools_event_filter.d.ts +5 -5
- package/dist/tools_event_filter.js +19 -11
- package/dist/tools_event_filter.js.map +1 -1
- package/package.json +15 -15
- package/source/resolve_operand.ts +4 -2
- package/source/tools_event_filter.ts +29 -22
package/dist/resolve_operand.js
CHANGED
|
@@ -8,6 +8,8 @@ const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
|
8
8
|
const node_opcua_types_1 = require("node-opcua-types");
|
|
9
9
|
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
10
10
|
const warningLog = (0, node_opcua_debug_1.make_warningLog)("FILTER");
|
|
11
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)("FILTER");
|
|
12
|
+
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)("FILTER");
|
|
11
13
|
// export function readOperand(context: FilterContext, operand: SimpleAttributeOperand): Variant {
|
|
12
14
|
// // navigate to the innerNode specified by the browsePath [ QualifiedName]
|
|
13
15
|
// const browsePath = constructBrowsePathFromQualifiedName({ nodeId: context.eventSource }, operand.browsePath);
|
|
@@ -27,7 +29,7 @@ function resolveOperand(context, operand) {
|
|
|
27
29
|
}
|
|
28
30
|
const nodeClass = context.getNodeClass(target);
|
|
29
31
|
if (nodeClass !== node_opcua_data_model_1.NodeClass.Variable) {
|
|
30
|
-
|
|
32
|
+
doDebug && debugLog("resolveOperand: cannot find variable here but got nodeClass", node_opcua_data_model_1.NodeClass[nodeClass], browsePath.toString());
|
|
31
33
|
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.StatusCode, value: node_opcua_status_code_1.StatusCodes.BadNodeClassInvalid });
|
|
32
34
|
}
|
|
33
35
|
const value = context.readNodeValue(target);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve_operand.js","sourceRoot":"","sources":["../source/resolve_operand.ts"],"names":[],"mappings":";;;AAAA,iEAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"resolve_operand.js","sourceRoot":"","sources":["../source/resolve_operand.ts"],"names":[],"mappings":";;;AAAA,iEAAkD;AAClD,uDAAkF;AAElF,uGAAgH;AAChH,mEAAqD;AACrD,uDAAgG;AAChG,2DAAuD;AAGvD,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,QAAQ,CAAC,CAAC;AAC7C,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,QAAQ,CAAC,CAAC;AACzC,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,QAAQ,CAAC,CAAC;AAEzC,kGAAkG;AAClG,gFAAgF;AAChF,oHAAoH;AACpH,yDAAyD;AACzD,yBAAyB;AACzB,2DAA2D;AAC3D,QAAQ;AACR,gDAAgD;AAChD,IAAI;AAEJ,SAAgB,cAAc,CAAC,OAAsB,EAAE,OAAkD;IACrG,IAAI,OAAO,YAAY,yCAAsB,EAAE;QAC3C,MAAM,UAAU,GAAG,IAAA,+EAAoC,EAAC,EAAE,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAE7G,MAAM,MAAM,GAAkB,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,EAAE;YACT,OAAO,IAAI,4BAAO,CAAC,EAAE,QAAQ,EAAE,6BAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAChD,8FAA8F;SACjG;QACD,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,SAAS,KAAK,iCAAS,CAAC,QAAQ,EAAE;YAClC,OAAO,IAAI,QAAQ,CAAC,6DAA6D,EAAE,iCAAS,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;YAChI,OAAO,IAAI,4BAAO,CAAC,EAAE,QAAQ,EAAE,6BAAQ,CAAC,UAAU,EAAE,KAAK,EAAE,oCAAW,CAAC,mBAAmB,EAAE,CAAC,CAAC;SACjG;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,OAAO,KAAK,CAAC;KAChB;SAAM;QACH,IAAI,CAAC,CAAC,OAAO,YAAY,mCAAgB,CAAC,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;SACpD;QACD,UAAU,CAAC,yCAAyC,CAAC,CAAC;QACtD,OAAO,IAAI,4BAAO,CAAC,EAAE,QAAQ,EAAE,6BAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;KACnD;AACL,CAAC;AAvBD,wCAuBC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { QualifiedName, QualifiedNameOptions } from "node-opcua-data-model";
|
|
1
2
|
import { ContentFilterElement, ContentFilterOptions, EventFilter, SimpleAttributeOperand } from "./imports";
|
|
2
|
-
export declare function
|
|
3
|
+
export declare function constructSimpleBrowsePath(a: string | string[] | (QualifiedNameOptions | string)[]): QualifiedName[];
|
|
4
|
+
export declare function constructSelectClause(arrayOfNames: string | string[] | (QualifiedNameOptions | string)[][]): SimpleAttributeOperand[];
|
|
3
5
|
/**
|
|
4
6
|
* helper to construct event filters:
|
|
5
7
|
* construct a simple event filter
|
|
@@ -9,12 +11,10 @@ export declare function constructSelectClause(arrayOfNames: string | string[]):
|
|
|
9
11
|
* @example
|
|
10
12
|
*
|
|
11
13
|
* constructEventFilter(["SourceName","Message","ReceiveTime"]);
|
|
12
|
-
*
|
|
13
|
-
* constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
|
|
14
14
|
* constructEventFilter(["SourceName","2:MyData" ]);
|
|
15
|
-
*
|
|
16
15
|
* constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
|
|
17
16
|
* constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
|
|
17
|
+
* constructEventFilter([ ["SourceName",{namespaceIndex:2 , "MyData"} ]]);
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
-
export declare function constructEventFilter(arrayOfNames: string[] | string, whereClause?: ContentFilterOptions | ContentFilterElement): EventFilter;
|
|
20
|
+
export declare function constructEventFilter(arrayOfNames: (QualifiedNameOptions | string)[][] | string[] | string, whereClause?: ContentFilterOptions | ContentFilterElement): EventFilter;
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.constructEventFilter = exports.constructSelectClause = void 0;
|
|
3
|
+
exports.constructEventFilter = exports.constructSelectClause = exports.constructSimpleBrowsePath = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @module node-opcua-service-filter
|
|
6
6
|
*/
|
|
7
7
|
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
8
8
|
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
9
9
|
const imports_1 = require("./imports");
|
|
10
|
+
function coerceQualifiedName2(a) {
|
|
11
|
+
if (typeof a === "string")
|
|
12
|
+
return (0, node_opcua_data_model_1.coerceQualifiedName)(a);
|
|
13
|
+
a.namespaceIndex = a.namespaceIndex || 0; // need a namespaceIndex
|
|
14
|
+
return (0, node_opcua_data_model_1.coerceQualifiedName)(a);
|
|
15
|
+
}
|
|
16
|
+
function constructSimpleBrowsePath(a) {
|
|
17
|
+
if (typeof a === "string") {
|
|
18
|
+
return constructSimpleBrowsePath(a.split("."));
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(a))
|
|
21
|
+
return a.map(coerceQualifiedName2);
|
|
22
|
+
return [coerceQualifiedName2(a)];
|
|
23
|
+
}
|
|
24
|
+
exports.constructSimpleBrowsePath = constructSimpleBrowsePath;
|
|
10
25
|
function constructSelectClause(arrayOfNames) {
|
|
11
26
|
if (!Array.isArray(arrayOfNames)) {
|
|
12
27
|
return constructSelectClause([arrayOfNames]);
|
|
13
28
|
}
|
|
14
|
-
// replace "string" element in the form A.B.C into [ "A","B","C"]
|
|
15
|
-
const arrayOfNames2 = arrayOfNames.map((path) => (typeof path !== "string" ? path : path.split(".")));
|
|
16
|
-
const arrayOfNames3 = arrayOfNames2.map((path) => (Array.isArray(path) ? path.map(node_opcua_data_model_1.stringToQualifiedName) : path));
|
|
17
|
-
// replace "string" elements in arrayOfName with QualifiedName in namespace 0
|
|
18
|
-
const arrayOfNames4 = arrayOfNames3.map((s) => (typeof s === "string" ? (0, node_opcua_data_model_1.stringToQualifiedName)(s) : s));
|
|
19
29
|
// construct browse paths array
|
|
20
|
-
const browsePaths =
|
|
30
|
+
const browsePaths = arrayOfNames.map(constructSimpleBrowsePath);
|
|
21
31
|
// Part 4 page 127:
|
|
22
32
|
// In some cases the same BrowsePath will apply to multiple EventTypes. If the Client specifies the BaseEventType
|
|
23
33
|
// in the SimpleAttributeOperand then the Server shall evaluate the BrowsePath without considering the Type.
|
|
24
|
-
const isBrowsePathForConditionId = (browsePath) => browsePath.length === 1 && browsePath[0].namespaceIndex === 0 && browsePath[0].name === "ConditionId";
|
|
34
|
+
const isBrowsePathForConditionId = (browsePath) => browsePath.length === 1 && browsePath[0] && browsePath[0].namespaceIndex === 0 && browsePath[0].name === "ConditionId";
|
|
25
35
|
// [..]
|
|
26
36
|
// The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only
|
|
27
37
|
// required to support the Value Attribute for Variable Nodes and the NodeId Attribute for Object Nodes.
|
|
@@ -67,12 +77,10 @@ exports.constructSelectClause = constructSelectClause;
|
|
|
67
77
|
* @example
|
|
68
78
|
*
|
|
69
79
|
* constructEventFilter(["SourceName","Message","ReceiveTime"]);
|
|
70
|
-
*
|
|
71
|
-
* constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
|
|
72
80
|
* constructEventFilter(["SourceName","2:MyData" ]);
|
|
73
|
-
*
|
|
74
81
|
* constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
|
|
75
82
|
* constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
|
|
83
|
+
* constructEventFilter([ ["SourceName",{namespaceIndex:2 , "MyData"} ]]);
|
|
76
84
|
*
|
|
77
85
|
*/
|
|
78
86
|
function constructEventFilter(arrayOfNames, whereClause) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools_event_filter.js","sourceRoot":"","sources":["../source/tools_event_filter.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,+DAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"tools_event_filter.js","sourceRoot":"","sources":["../source/tools_event_filter.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-service-filter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.109.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module service-filter",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -10,23 +10,23 @@
|
|
|
10
10
|
"build": "tsc -b"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"node-opcua-address-space-base": "2.
|
|
13
|
+
"node-opcua-address-space-base": "2.109.0",
|
|
14
14
|
"node-opcua-assert": "2.105.0",
|
|
15
|
-
"node-opcua-basic-types": "2.
|
|
15
|
+
"node-opcua-basic-types": "2.109.0",
|
|
16
16
|
"node-opcua-constants": "2.98.1",
|
|
17
|
-
"node-opcua-data-model": "2.
|
|
18
|
-
"node-opcua-data-value": "2.
|
|
19
|
-
"node-opcua-debug": "2.
|
|
20
|
-
"node-opcua-extension-object": "2.
|
|
21
|
-
"node-opcua-nodeid": "2.
|
|
22
|
-
"node-opcua-service-translate-browse-path": "2.
|
|
23
|
-
"node-opcua-status-code": "2.
|
|
24
|
-
"node-opcua-types": "2.
|
|
25
|
-
"node-opcua-variant": "2.
|
|
17
|
+
"node-opcua-data-model": "2.109.0",
|
|
18
|
+
"node-opcua-data-value": "2.109.0",
|
|
19
|
+
"node-opcua-debug": "2.109.0",
|
|
20
|
+
"node-opcua-extension-object": "2.109.0",
|
|
21
|
+
"node-opcua-nodeid": "2.109.0",
|
|
22
|
+
"node-opcua-service-translate-browse-path": "2.109.0",
|
|
23
|
+
"node-opcua-status-code": "2.109.0",
|
|
24
|
+
"node-opcua-types": "2.109.0",
|
|
25
|
+
"node-opcua-variant": "2.109.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"node-opcua-numeric-range": "2.
|
|
29
|
-
"node-opcua-packet-analyzer": "2.
|
|
28
|
+
"node-opcua-numeric-range": "2.109.0",
|
|
29
|
+
"node-opcua-packet-analyzer": "2.109.0",
|
|
30
30
|
"should": "^13.2.3"
|
|
31
31
|
},
|
|
32
32
|
"author": "Etienne Rossignon",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"internet of things"
|
|
45
45
|
],
|
|
46
46
|
"homepage": "http://node-opcua.github.io/",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "50cfa07779d4c07b299176ac9c27527fcd97d079",
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|
|
50
50
|
"source"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeClass } from "node-opcua-data-model";
|
|
2
|
-
import { make_warningLog } from "node-opcua-debug";
|
|
2
|
+
import { checkDebugFlag, make_debugLog, make_warningLog } from "node-opcua-debug";
|
|
3
3
|
import { NodeId } from "node-opcua-nodeid";
|
|
4
4
|
import { constructBrowsePathFromQualifiedName, makeBrowsePath } from "node-opcua-service-translate-browse-path";
|
|
5
5
|
import { StatusCodes } from "node-opcua-status-code";
|
|
@@ -8,6 +8,8 @@ import { DataType, Variant } from "node-opcua-variant";
|
|
|
8
8
|
import { FilterContext } from "./filter_context";
|
|
9
9
|
|
|
10
10
|
const warningLog = make_warningLog("FILTER");
|
|
11
|
+
const debugLog = make_debugLog("FILTER");
|
|
12
|
+
const doDebug = checkDebugFlag("FILTER");
|
|
11
13
|
|
|
12
14
|
// export function readOperand(context: FilterContext, operand: SimpleAttributeOperand): Variant {
|
|
13
15
|
// // navigate to the innerNode specified by the browsePath [ QualifiedName]
|
|
@@ -30,7 +32,7 @@ export function resolveOperand(context: FilterContext, operand: SimpleAttributeO
|
|
|
30
32
|
}
|
|
31
33
|
const nodeClass = context.getNodeClass(target);
|
|
32
34
|
if (nodeClass !== NodeClass.Variable) {
|
|
33
|
-
|
|
35
|
+
doDebug && debugLog("resolveOperand: cannot find variable here but got nodeClass", NodeClass[nodeClass], browsePath.toString());
|
|
34
36
|
return new Variant({ dataType: DataType.StatusCode, value: StatusCodes.BadNodeClassInvalid });
|
|
35
37
|
}
|
|
36
38
|
const value = context.readNodeValue(target);
|
|
@@ -2,41 +2,50 @@
|
|
|
2
2
|
* @module node-opcua-service-filter
|
|
3
3
|
*/
|
|
4
4
|
import { ObjectTypeIds } from "node-opcua-constants";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
AttributeIds,
|
|
7
|
+
QualifiedName,
|
|
8
|
+
QualifiedNameOptions,
|
|
9
|
+
coerceQualifiedName,
|
|
10
|
+
stringToQualifiedName
|
|
11
|
+
} from "node-opcua-data-model";
|
|
7
12
|
|
|
8
|
-
import { ContentFilter, ContentFilterElement, ContentFilterOptions, EventFilter,
|
|
13
|
+
import { ContentFilter, ContentFilterElement, ContentFilterOptions, EventFilter, SimpleAttributeOperand } from "./imports";
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
function coerceQualifiedName2(a: string | QualifiedNameOptions) {
|
|
16
|
+
if (typeof a === "string") return coerceQualifiedName(a);
|
|
17
|
+
a.namespaceIndex = a.namespaceIndex || 0; // need a namespaceIndex
|
|
18
|
+
return coerceQualifiedName(a);
|
|
19
|
+
}
|
|
11
20
|
|
|
12
|
-
export function
|
|
21
|
+
export function constructSimpleBrowsePath(a: string | string[] | (QualifiedNameOptions | string)[]): QualifiedName[] {
|
|
22
|
+
if (typeof a === "string") {
|
|
23
|
+
return constructSimpleBrowsePath(a.split("."));
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(a)) return a.map(coerceQualifiedName2);
|
|
26
|
+
return [coerceQualifiedName2(a)];
|
|
27
|
+
}
|
|
28
|
+
export function constructSelectClause(
|
|
29
|
+
arrayOfNames: string | string[] | (QualifiedNameOptions | string)[][]
|
|
30
|
+
): SimpleAttributeOperand[] {
|
|
13
31
|
if (!Array.isArray(arrayOfNames)) {
|
|
14
32
|
return constructSelectClause([arrayOfNames]);
|
|
15
33
|
}
|
|
16
|
-
|
|
17
|
-
// replace "string" element in the form A.B.C into [ "A","B","C"]
|
|
18
|
-
const arrayOfNames2 = arrayOfNames.map((path) => (typeof path !== "string" ? path : path.split(".")));
|
|
19
|
-
|
|
20
|
-
const arrayOfNames3 = arrayOfNames2.map((path) => (Array.isArray(path) ? path.map(stringToQualifiedName) : path));
|
|
21
|
-
|
|
22
|
-
// replace "string" elements in arrayOfName with QualifiedName in namespace 0
|
|
23
|
-
const arrayOfNames4 = arrayOfNames3.map((s) => (typeof s === "string" ? stringToQualifiedName(s) : s));
|
|
24
|
-
|
|
25
34
|
// construct browse paths array
|
|
26
|
-
const browsePaths =
|
|
35
|
+
const browsePaths = arrayOfNames.map(constructSimpleBrowsePath);
|
|
27
36
|
|
|
28
37
|
// Part 4 page 127:
|
|
29
38
|
// In some cases the same BrowsePath will apply to multiple EventTypes. If the Client specifies the BaseEventType
|
|
30
39
|
// in the SimpleAttributeOperand then the Server shall evaluate the BrowsePath without considering the Type.
|
|
31
40
|
|
|
32
|
-
const isBrowsePathForConditionId = (browsePath:
|
|
33
|
-
browsePath.length === 1 && browsePath[0].namespaceIndex === 0 && browsePath[0].name === "ConditionId";
|
|
41
|
+
const isBrowsePathForConditionId = (browsePath: QualifiedNameOptions[]) =>
|
|
42
|
+
browsePath.length === 1 && browsePath[0] && browsePath[0].namespaceIndex === 0 && browsePath[0].name === "ConditionId";
|
|
34
43
|
|
|
35
44
|
// [..]
|
|
36
45
|
// The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only
|
|
37
46
|
// required to support the Value Attribute for Variable Nodes and the NodeId Attribute for Object Nodes.
|
|
38
47
|
// That said, profiles defined in Part 7 may make support for additional Attributes mandatory.
|
|
39
|
-
const selectClauses = browsePaths.map((browsePath:
|
|
48
|
+
const selectClauses = browsePaths.map((browsePath: QualifiedNameOptions[]) => {
|
|
40
49
|
if (isBrowsePathForConditionId(browsePath)) {
|
|
41
50
|
// special case
|
|
42
51
|
//
|
|
@@ -75,16 +84,14 @@ export function constructSelectClause(arrayOfNames: string | string[]): SimpleAt
|
|
|
75
84
|
* @example
|
|
76
85
|
*
|
|
77
86
|
* constructEventFilter(["SourceName","Message","ReceiveTime"]);
|
|
78
|
-
*
|
|
79
|
-
* constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
|
|
80
87
|
* constructEventFilter(["SourceName","2:MyData" ]);
|
|
81
|
-
*
|
|
82
88
|
* constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
|
|
83
89
|
* constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
|
|
90
|
+
* constructEventFilter([ ["SourceName",{namespaceIndex:2 , "MyData"} ]]);
|
|
84
91
|
*
|
|
85
92
|
*/
|
|
86
93
|
export function constructEventFilter(
|
|
87
|
-
arrayOfNames: string[] | string,
|
|
94
|
+
arrayOfNames: (QualifiedNameOptions | string)[][] | string[] | string,
|
|
88
95
|
whereClause?: ContentFilterOptions | ContentFilterElement
|
|
89
96
|
): EventFilter {
|
|
90
97
|
const selectClauses = constructSelectClause(arrayOfNames);
|