node-opcua-service-filter 2.97.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,45 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveOperand = void 0;
4
- const node_opcua_data_model_1 = require("node-opcua-data-model");
5
- const node_opcua_debug_1 = require("node-opcua-debug");
6
- const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
7
- const node_opcua_status_code_1 = require("node-opcua-status-code");
8
- const node_opcua_types_1 = require("node-opcua-types");
9
- const node_opcua_variant_1 = require("node-opcua-variant");
10
- const warningLog = (0, node_opcua_debug_1.make_warningLog)("FILTER");
11
- // export function readOperand(context: FilterContext, operand: SimpleAttributeOperand): Variant {
12
- // // navigate to the innerNode specified by the browsePath [ QualifiedName]
13
- // const browsePath = constructBrowsePathFromQualifiedName({ nodeId: context.eventSource }, operand.browsePath);
14
- // const targetNode = context.browsePath(browsePath);
15
- // if (!targetNode) {
16
- // return new Variant({ dataType: DataType.Null });
17
- // }
18
- // return context.readNodeValue(targetNode);
19
- // }
20
- function resolveOperand(context, operand) {
21
- if (operand instanceof node_opcua_types_1.SimpleAttributeOperand) {
22
- const browsePath = (0, node_opcua_service_translate_browse_path_1.constructBrowsePathFromQualifiedName)({ nodeId: context.eventSource }, operand.browsePath);
23
- const target = context.browsePath(browsePath);
24
- if (!target) {
25
- return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null });
26
- // return new Variant({ dataType: DataType.StatusCode, value: StatusCodes.BadNodeIdUnknown });
27
- }
28
- const nodeClass = context.getNodeClass(target);
29
- if (nodeClass !== node_opcua_data_model_1.NodeClass.Variable) {
30
- warningLog("resolveOperand: cannot find variable here but got nodeClass", node_opcua_data_model_1.NodeClass[nodeClass], browsePath.toString());
31
- return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.StatusCode, value: node_opcua_status_code_1.StatusCodes.BadNodeClassInvalid });
32
- }
33
- const value = context.readNodeValue(target);
34
- return value;
35
- }
36
- else {
37
- if (!(operand instanceof node_opcua_types_1.AttributeOperand)) {
38
- throw new Error("expecting an AttributeOperand");
39
- }
40
- warningLog("AttributeOperand is not yet implemented");
41
- return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null });
42
- }
43
- }
44
- exports.resolveOperand = resolveOperand;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveOperand = void 0;
4
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
5
+ const node_opcua_debug_1 = require("node-opcua-debug");
6
+ const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
7
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
8
+ const node_opcua_types_1 = require("node-opcua-types");
9
+ const node_opcua_variant_1 = require("node-opcua-variant");
10
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)("FILTER");
11
+ // export function readOperand(context: FilterContext, operand: SimpleAttributeOperand): Variant {
12
+ // // navigate to the innerNode specified by the browsePath [ QualifiedName]
13
+ // const browsePath = constructBrowsePathFromQualifiedName({ nodeId: context.eventSource }, operand.browsePath);
14
+ // const targetNode = context.browsePath(browsePath);
15
+ // if (!targetNode) {
16
+ // return new Variant({ dataType: DataType.Null });
17
+ // }
18
+ // return context.readNodeValue(targetNode);
19
+ // }
20
+ function resolveOperand(context, operand) {
21
+ if (operand instanceof node_opcua_types_1.SimpleAttributeOperand) {
22
+ const browsePath = (0, node_opcua_service_translate_browse_path_1.constructBrowsePathFromQualifiedName)({ nodeId: context.eventSource }, operand.browsePath);
23
+ const target = context.browsePath(browsePath);
24
+ if (!target) {
25
+ return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null });
26
+ // return new Variant({ dataType: DataType.StatusCode, value: StatusCodes.BadNodeIdUnknown });
27
+ }
28
+ const nodeClass = context.getNodeClass(target);
29
+ if (nodeClass !== node_opcua_data_model_1.NodeClass.Variable) {
30
+ warningLog("resolveOperand: cannot find variable here but got nodeClass", node_opcua_data_model_1.NodeClass[nodeClass], browsePath.toString());
31
+ return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.StatusCode, value: node_opcua_status_code_1.StatusCodes.BadNodeClassInvalid });
32
+ }
33
+ const value = context.readNodeValue(target);
34
+ return value;
35
+ }
36
+ else {
37
+ if (!(operand instanceof node_opcua_types_1.AttributeOperand)) {
38
+ throw new Error("expecting an AttributeOperand");
39
+ }
40
+ warningLog("AttributeOperand is not yet implemented");
41
+ return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null });
42
+ }
43
+ }
44
+ exports.resolveOperand = resolveOperand;
45
45
  //# sourceMappingURL=resolve_operand.js.map
@@ -1,20 +1,20 @@
1
- import { ContentFilterElement, ContentFilterOptions, EventFilter, SimpleAttributeOperand } from "./imports";
2
- export declare function constructSelectClause(arrayOfNames: string | string[]): SimpleAttributeOperand[];
3
- /**
4
- * helper to construct event filters:
5
- * construct a simple event filter
6
- *
7
- * "ConditionId" in the arrayOfNames has a special meaning
8
- *
9
- * @example
10
- *
11
- * constructEventFilter(["SourceName","Message","ReceiveTime"]);
12
- *
13
- * constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
14
- * constructEventFilter(["SourceName","2:MyData" ]);
15
- *
16
- * constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
17
- * constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
18
- *
19
- */
20
- export declare function constructEventFilter(arrayOfNames: string[] | string, whereClause?: ContentFilterOptions | ContentFilterElement): EventFilter;
1
+ import { ContentFilterElement, ContentFilterOptions, EventFilter, SimpleAttributeOperand } from "./imports";
2
+ export declare function constructSelectClause(arrayOfNames: string | string[]): SimpleAttributeOperand[];
3
+ /**
4
+ * helper to construct event filters:
5
+ * construct a simple event filter
6
+ *
7
+ * "ConditionId" in the arrayOfNames has a special meaning
8
+ *
9
+ * @example
10
+ *
11
+ * constructEventFilter(["SourceName","Message","ReceiveTime"]);
12
+ *
13
+ * constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
14
+ * constructEventFilter(["SourceName","2:MyData" ]);
15
+ *
16
+ * constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
17
+ * constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
18
+ *
19
+ */
20
+ export declare function constructEventFilter(arrayOfNames: string[] | string, whereClause?: ContentFilterOptions | ContentFilterElement): EventFilter;
@@ -1,90 +1,90 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.constructEventFilter = exports.constructSelectClause = void 0;
4
- /**
5
- * @module node-opcua-service-filter
6
- */
7
- const node_opcua_constants_1 = require("node-opcua-constants");
8
- const node_opcua_data_model_1 = require("node-opcua-data-model");
9
- const imports_1 = require("./imports");
10
- function constructSelectClause(arrayOfNames) {
11
- if (!Array.isArray(arrayOfNames)) {
12
- return constructSelectClause([arrayOfNames]);
13
- }
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
- // construct browse paths array
20
- const browsePaths = arrayOfNames4.map((s) => (Array.isArray(s) ? s : [s]));
21
- // Part 4 page 127:
22
- // In some cases the same BrowsePath will apply to multiple EventTypes. If the Client specifies the BaseEventType
23
- // 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";
25
- // [..]
26
- // The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only
27
- // required to support the Value Attribute for Variable Nodes and the NodeId Attribute for Object Nodes.
28
- // That said, profiles defined in Part 7 may make support for additional Attributes mandatory.
29
- const selectClauses = browsePaths.map((browsePath) => {
30
- if (isBrowsePathForConditionId(browsePath)) {
31
- // special case
32
- //
33
- // The NodeId of the Condition instance is used as ConditionId. It is not explicitly modelled as a
34
- // component of the ConditionType. However, it can be requested with the following
35
- // SimpleAttributeOperand (see Table 10) in the SelectClause of the EventFilter:
36
- //
37
- // SimpleAttributeOperand
38
- // Name Type Description
39
- // typeId NodeId NodeId of the ConditionType Node
40
- // browsePath[] QualifiedName empty
41
- // attributeId IntegerId Id of the NodeId Attribute
42
- //
43
- return new imports_1.SimpleAttributeOperand({
44
- attributeId: node_opcua_data_model_1.AttributeIds.NodeId,
45
- browsePath: null,
46
- indexRange: undefined,
47
- typeDefinitionId: node_opcua_constants_1.ObjectTypeIds.ConditionType // i=2782
48
- });
49
- }
50
- else
51
- return new imports_1.SimpleAttributeOperand({
52
- attributeId: node_opcua_data_model_1.AttributeIds.Value,
53
- browsePath,
54
- indexRange: undefined,
55
- typeDefinitionId: node_opcua_constants_1.ObjectTypeIds.BaseEventType // i=2041
56
- });
57
- });
58
- return selectClauses;
59
- }
60
- exports.constructSelectClause = constructSelectClause;
61
- /**
62
- * helper to construct event filters:
63
- * construct a simple event filter
64
- *
65
- * "ConditionId" in the arrayOfNames has a special meaning
66
- *
67
- * @example
68
- *
69
- * constructEventFilter(["SourceName","Message","ReceiveTime"]);
70
- *
71
- * constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
72
- * constructEventFilter(["SourceName","2:MyData" ]);
73
- *
74
- * constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
75
- * constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
76
- *
77
- */
78
- function constructEventFilter(arrayOfNames, whereClause) {
79
- const selectClauses = constructSelectClause(arrayOfNames);
80
- if (whereClause instanceof imports_1.ContentFilterElement) {
81
- whereClause = new imports_1.ContentFilter({ elements: [whereClause] });
82
- }
83
- const filter = new imports_1.EventFilter({
84
- selectClauses,
85
- whereClause
86
- });
87
- return filter;
88
- }
89
- exports.constructEventFilter = constructEventFilter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constructEventFilter = exports.constructSelectClause = void 0;
4
+ /**
5
+ * @module node-opcua-service-filter
6
+ */
7
+ const node_opcua_constants_1 = require("node-opcua-constants");
8
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
9
+ const imports_1 = require("./imports");
10
+ function constructSelectClause(arrayOfNames) {
11
+ if (!Array.isArray(arrayOfNames)) {
12
+ return constructSelectClause([arrayOfNames]);
13
+ }
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
+ // construct browse paths array
20
+ const browsePaths = arrayOfNames4.map((s) => (Array.isArray(s) ? s : [s]));
21
+ // Part 4 page 127:
22
+ // In some cases the same BrowsePath will apply to multiple EventTypes. If the Client specifies the BaseEventType
23
+ // 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";
25
+ // [..]
26
+ // The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only
27
+ // required to support the Value Attribute for Variable Nodes and the NodeId Attribute for Object Nodes.
28
+ // That said, profiles defined in Part 7 may make support for additional Attributes mandatory.
29
+ const selectClauses = browsePaths.map((browsePath) => {
30
+ if (isBrowsePathForConditionId(browsePath)) {
31
+ // special case
32
+ //
33
+ // The NodeId of the Condition instance is used as ConditionId. It is not explicitly modelled as a
34
+ // component of the ConditionType. However, it can be requested with the following
35
+ // SimpleAttributeOperand (see Table 10) in the SelectClause of the EventFilter:
36
+ //
37
+ // SimpleAttributeOperand
38
+ // Name Type Description
39
+ // typeId NodeId NodeId of the ConditionType Node
40
+ // browsePath[] QualifiedName empty
41
+ // attributeId IntegerId Id of the NodeId Attribute
42
+ //
43
+ return new imports_1.SimpleAttributeOperand({
44
+ attributeId: node_opcua_data_model_1.AttributeIds.NodeId,
45
+ browsePath: null,
46
+ indexRange: undefined,
47
+ typeDefinitionId: node_opcua_constants_1.ObjectTypeIds.ConditionType // i=2782
48
+ });
49
+ }
50
+ else
51
+ return new imports_1.SimpleAttributeOperand({
52
+ attributeId: node_opcua_data_model_1.AttributeIds.Value,
53
+ browsePath,
54
+ indexRange: undefined,
55
+ typeDefinitionId: node_opcua_constants_1.ObjectTypeIds.BaseEventType // i=2041
56
+ });
57
+ });
58
+ return selectClauses;
59
+ }
60
+ exports.constructSelectClause = constructSelectClause;
61
+ /**
62
+ * helper to construct event filters:
63
+ * construct a simple event filter
64
+ *
65
+ * "ConditionId" in the arrayOfNames has a special meaning
66
+ *
67
+ * @example
68
+ *
69
+ * constructEventFilter(["SourceName","Message","ReceiveTime"]);
70
+ *
71
+ * constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
72
+ * constructEventFilter(["SourceName","2:MyData" ]);
73
+ *
74
+ * constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
75
+ * constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
76
+ *
77
+ */
78
+ function constructEventFilter(arrayOfNames, whereClause) {
79
+ const selectClauses = constructSelectClause(arrayOfNames);
80
+ if (whereClause instanceof imports_1.ContentFilterElement) {
81
+ whereClause = new imports_1.ContentFilter({ elements: [whereClause] });
82
+ }
83
+ const filter = new imports_1.EventFilter({
84
+ selectClauses,
85
+ whereClause
86
+ });
87
+ return filter;
88
+ }
89
+ exports.constructEventFilter = constructEventFilter;
90
90
  //# sourceMappingURL=tools_event_filter.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-opcua-service-filter",
3
- "version": "2.97.0",
4
- "description": "pure nodejs OPCUA SDK - module -service-filter",
3
+ "version": "2.98.1",
4
+ "description": "pure nodejs OPCUA SDK - module service-filter",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
@@ -10,23 +10,23 @@
10
10
  "build": "tsc -b"
11
11
  },
12
12
  "dependencies": {
13
- "node-opcua-address-space-base": "2.97.0",
14
- "node-opcua-assert": "2.88.0",
15
- "node-opcua-basic-types": "2.97.0",
16
- "node-opcua-constants": "2.88.0",
17
- "node-opcua-data-model": "2.97.0",
18
- "node-opcua-data-value": "2.97.0",
19
- "node-opcua-debug": "2.90.1",
20
- "node-opcua-extension-object": "2.97.0",
21
- "node-opcua-nodeid": "2.97.0",
22
- "node-opcua-service-translate-browse-path": "2.97.0",
23
- "node-opcua-status-code": "2.90.1",
24
- "node-opcua-types": "2.97.0",
25
- "node-opcua-variant": "2.97.0"
13
+ "node-opcua-address-space-base": "2.98.1",
14
+ "node-opcua-assert": "2.98.1",
15
+ "node-opcua-basic-types": "2.98.1",
16
+ "node-opcua-constants": "2.98.1",
17
+ "node-opcua-data-model": "2.98.1",
18
+ "node-opcua-data-value": "2.98.1",
19
+ "node-opcua-debug": "2.98.1",
20
+ "node-opcua-extension-object": "2.98.1",
21
+ "node-opcua-nodeid": "2.98.1",
22
+ "node-opcua-service-translate-browse-path": "2.98.1",
23
+ "node-opcua-status-code": "2.98.1",
24
+ "node-opcua-types": "2.98.1",
25
+ "node-opcua-variant": "2.98.1"
26
26
  },
27
27
  "devDependencies": {
28
- "node-opcua-numeric-range": "2.97.0",
29
- "node-opcua-packet-analyzer": "2.97.0",
28
+ "node-opcua-numeric-range": "2.98.1",
29
+ "node-opcua-packet-analyzer": "2.98.1",
30
30
  "should": "^13.2.3"
31
31
  },
32
32
  "author": "Etienne Rossignon",
@@ -44,5 +44,9 @@
44
44
  "internet of things"
45
45
  ],
46
46
  "homepage": "http://node-opcua.github.io/",
47
- "gitHead": "19c96bda0810d2dec73dd1c2427546be40908646"
47
+ "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c",
48
+ "files": [
49
+ "dist",
50
+ "source"
51
+ ]
48
52
  }