node-opcua-service-filter 2.74.0 → 2.75.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 (45) hide show
  1. package/dist/check_event_clause.d.ts +17 -0
  2. package/dist/check_event_clause.js +52 -0
  3. package/dist/check_event_clause.js.map +1 -0
  4. package/dist/check_where_clause.d.ts +3 -0
  5. package/dist/check_where_clause.js +250 -0
  6. package/dist/check_where_clause.js.map +1 -0
  7. package/dist/extract_event_field.d.ts +9 -0
  8. package/dist/extract_event_field.js +53 -0
  9. package/dist/extract_event_field.js.map +1 -0
  10. package/dist/filter_context.d.ts +11 -0
  11. package/dist/filter_context.js +3 -0
  12. package/dist/filter_context.js.map +1 -0
  13. package/dist/index.d.ts +8 -0
  14. package/dist/index.js +8 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/make_content_filter.d.ts +22 -0
  17. package/dist/make_content_filter.js +121 -0
  18. package/dist/make_content_filter.js.map +1 -0
  19. package/dist/on_address_space/extract_event_fields.d.ts +10 -0
  20. package/dist/on_address_space/extract_event_fields.js +18 -0
  21. package/dist/on_address_space/extract_event_fields.js.map +1 -0
  22. package/dist/on_address_space/filter_context_on_address_space.d.ts +19 -0
  23. package/dist/on_address_space/filter_context_on_address_space.js +109 -0
  24. package/dist/on_address_space/filter_context_on_address_space.js.map +1 -0
  25. package/dist/on_address_space/index.d.ts +2 -0
  26. package/dist/on_address_space/index.js +19 -0
  27. package/dist/on_address_space/index.js.map +1 -0
  28. package/dist/resolve_operand.d.ts +4 -0
  29. package/dist/resolve_operand.js +45 -0
  30. package/dist/resolve_operand.js.map +1 -0
  31. package/dist/tools_event_filter.d.ts +4 -16
  32. package/dist/tools_event_filter.js +53 -121
  33. package/dist/tools_event_filter.js.map +1 -1
  34. package/package.json +13 -9
  35. package/source/check_event_clause.ts +54 -0
  36. package/source/check_where_clause.ts +287 -0
  37. package/source/extract_event_field.ts +55 -0
  38. package/source/filter_context.ts +15 -0
  39. package/source/index.ts +8 -0
  40. package/source/make_content_filter.ts +132 -0
  41. package/source/on_address_space/extract_event_fields.ts +24 -0
  42. package/source/on_address_space/filter_context_on_address_space.ts +134 -0
  43. package/source/on_address_space/index.ts +3 -0
  44. package/source/resolve_operand.ts +45 -0
  45. package/source/tools_event_filter.ts +61 -129
@@ -0,0 +1,17 @@
1
+ import { SimpleAttributeOperand } from "node-opcua-types";
2
+ import { StatusCode } from "node-opcua-status-code";
3
+ import { BaseNode, UAObjectType } from "node-opcua-address-space-base";
4
+ /**
5
+ * @method checkSelectClause
6
+ * @param parentNode
7
+ * @param selectClause
8
+ * @return {Array<StatusCode>}
9
+ */
10
+ export declare function checkSelectClause(parentNode: BaseNode, selectClause: SimpleAttributeOperand): StatusCode;
11
+ /**
12
+ * @method checkSelectClauses
13
+ * @param eventTypeNode
14
+ * @param selectClauses
15
+ * @return an array of StatusCode
16
+ */
17
+ export declare function checkSelectClauses(eventTypeNode: UAObjectType, selectClauses: SimpleAttributeOperand[]): StatusCode[];
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkSelectClauses = exports.checkSelectClause = void 0;
4
+ /**
5
+ * @module node-opcua-address-space
6
+ */
7
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
8
+ const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
9
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
10
+ /**
11
+ * @method checkSelectClause
12
+ * @param parentNode
13
+ * @param selectClause
14
+ * @return {Array<StatusCode>}
15
+ */
16
+ function checkSelectClause(parentNode, selectClause) {
17
+ //
18
+ const addressSpace = parentNode.addressSpace;
19
+ // istanbul ignore next
20
+ if (selectClause.typeDefinitionId.isEmpty()) {
21
+ return node_opcua_status_code_1.StatusCodes.Good;
22
+ }
23
+ const eventTypeNode = addressSpace.findEventType(selectClause.typeDefinitionId);
24
+ if (!eventTypeNode || !(eventTypeNode.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType)) {
25
+ // xx console.log("eventTypeNode = ",selectClause.typeDefinitionId.toString());
26
+ // xx console.log("eventTypeNode = ",eventTypeNode);
27
+ // istanbul ignore next
28
+ if (eventTypeNode) {
29
+ console.log(eventTypeNode.toString());
30
+ }
31
+ }
32
+ // istanbul ignore next
33
+ if (eventTypeNode.nodeClass !== node_opcua_data_model_1.NodeClass.ObjectType) {
34
+ return node_opcua_status_code_1.StatusCodes.BadTypeMismatch;
35
+ }
36
+ // navigate to the innerNode specified by the browsePath [ QualifiedName]
37
+ const browsePath = (0, node_opcua_service_translate_browse_path_1.constructBrowsePathFromQualifiedName)(eventTypeNode, selectClause.browsePath);
38
+ const browsePathResult = addressSpace.browsePath(browsePath);
39
+ return browsePathResult.statusCode;
40
+ }
41
+ exports.checkSelectClause = checkSelectClause;
42
+ /**
43
+ * @method checkSelectClauses
44
+ * @param eventTypeNode
45
+ * @param selectClauses
46
+ * @return an array of StatusCode
47
+ */
48
+ function checkSelectClauses(eventTypeNode, selectClauses) {
49
+ return selectClauses.map(checkSelectClause.bind(null, eventTypeNode));
50
+ }
51
+ exports.checkSelectClauses = checkSelectClauses;
52
+ //# sourceMappingURL=check_event_clause.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check_event_clause.js","sourceRoot":"","sources":["../source/check_event_clause.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,iEAAkD;AAElD,uGAAgG;AAChG,mEAAiE;AAGjE;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,UAAoB,EAAE,YAAoC;IACxF,EAAE;IACF,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;IAE7C,uBAAuB;IACvB,IAAI,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE;QACzC,OAAO,oCAAW,CAAC,IAAI,CAAC;KAC3B;IACD,MAAM,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC,YAAY,CAAC,gBAAgB,CAAE,CAAC;IAEjF,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,CAAC,SAAS,KAAK,iCAAS,CAAC,UAAU,CAAC,EAAE;QACvE,+EAA+E;QAC/E,oDAAoD;QACpD,uBAAuB;QACvB,IAAI,aAAa,EAAE;YACf,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;SACzC;KACJ;IAED,uBAAuB;IACvB,IAAI,aAAa,CAAC,SAAS,KAAK,iCAAS,CAAC,UAAU,EAAE;QAClD,OAAO,oCAAW,CAAC,eAAe,CAAC;KACtC;IAED,yEAAyE;IACzE,MAAM,UAAU,GAAG,IAAA,+EAAoC,EAAC,aAAa,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IAChG,MAAM,gBAAgB,GAAG,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC7D,OAAO,gBAAgB,CAAC,UAAU,CAAC;AACvC,CAAC;AA5BD,8CA4BC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,aAA2B,EAAE,aAAuC;IACnG,OAAO,aAAa,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;AAC1E,CAAC;AAFD,gDAEC"}
@@ -0,0 +1,3 @@
1
+ import { ContentFilter } from "node-opcua-types";
2
+ import { FilterContext } from "./filter_context";
3
+ export declare function checkFilter(filterContext: FilterContext, contentFilter: ContentFilter): boolean;
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkFilter = void 0;
4
+ const node_opcua_types_1 = require("node-opcua-types");
5
+ const node_opcua_variant_1 = require("node-opcua-variant");
6
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
7
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
8
+ const node_opcua_debug_1 = require("node-opcua-debug");
9
+ const resolve_operand_1 = require("./resolve_operand");
10
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)("Filter");
11
+ function _coerceToBoolean(value) {
12
+ if (value instanceof node_opcua_variant_1.Variant) {
13
+ return _coerceToBoolean(value.value);
14
+ }
15
+ return !!value;
16
+ }
17
+ function _coerceToNumber(value) {
18
+ if (value instanceof node_opcua_variant_1.Variant) {
19
+ return _coerceToNumber(value.value);
20
+ }
21
+ if (typeof value === "string") {
22
+ return parseInt(value, 10);
23
+ }
24
+ if (typeof value === "boolean") {
25
+ return value ? 1 : 0;
26
+ }
27
+ if (typeof value === "number") {
28
+ return value;
29
+ }
30
+ return 0;
31
+ }
32
+ function evaluateOperand(filterContext, filter, operand, coerce) {
33
+ if (operand instanceof node_opcua_types_1.AttributeOperand) {
34
+ return coerce((0, resolve_operand_1.resolveOperand)(filterContext, operand));
35
+ }
36
+ else if (operand instanceof node_opcua_types_1.SimpleAttributeOperand) {
37
+ return coerce((0, resolve_operand_1.resolveOperand)(filterContext, operand));
38
+ }
39
+ else if (operand instanceof node_opcua_types_1.LiteralOperand) {
40
+ return coerce(operand.value);
41
+ }
42
+ else if (operand instanceof node_opcua_types_1.ElementOperand) {
43
+ const index = operand.index;
44
+ return coerce(checkFilterAtIndex(filterContext, filter, index));
45
+ }
46
+ // istanbul ignore
47
+ return coerce(null);
48
+ }
49
+ function checkOfType(filterContext, ofType) {
50
+ // istanbul ignore next
51
+ if (!ofType || !(ofType instanceof node_opcua_types_1.LiteralOperand)) {
52
+ warningLog("checkOfType : unsupported case ! ofType is not a LiteralOperand , ofType = ", ofType === null || ofType === void 0 ? void 0 : ofType.toString());
53
+ return false;
54
+ }
55
+ // istanbul ignore next
56
+ if (ofType.value.dataType !== node_opcua_variant_1.DataType.NodeId) {
57
+ warningLog("invalid operand type (expecting NodeId); got " + node_opcua_variant_1.DataType[ofType.value.dataType]);
58
+ return false;
59
+ }
60
+ const ofTypeNode = ofType.value.value;
61
+ // istanbul ignore next
62
+ if (!ofTypeNode) {
63
+ return false; // the ofType node is not known, we don't know what to do
64
+ }
65
+ const ofTypeNodeNodeClass = filterContext.getNodeClass(ofTypeNode);
66
+ // istanbul ignore next
67
+ if (ofTypeNodeNodeClass !== node_opcua_data_model_1.NodeClass.ObjectType &&
68
+ ofTypeNodeNodeClass !== node_opcua_data_model_1.NodeClass.VariableType &&
69
+ ofTypeNodeNodeClass !== node_opcua_data_model_1.NodeClass.DataType &&
70
+ ofTypeNodeNodeClass !== node_opcua_data_model_1.NodeClass.ReferenceType) {
71
+ warningLog("operand should be a ObjectType " + ofTypeNode.toString());
72
+ return false;
73
+ }
74
+ if (!filterContext.eventSource || filterContext.eventSource.isEmpty()) {
75
+ return false;
76
+ }
77
+ let sourceTypeDefinition = filterContext.eventSource;
78
+ const sourceNodeClass = filterContext.getNodeClass(filterContext.eventSource);
79
+ if (sourceNodeClass === node_opcua_data_model_1.NodeClass.Object || sourceNodeClass === node_opcua_data_model_1.NodeClass.Variable) {
80
+ sourceTypeDefinition = filterContext.getTypeDefinition(filterContext.eventSource);
81
+ if (!sourceTypeDefinition) {
82
+ return false;
83
+ }
84
+ }
85
+ return filterContext.isSubtypeOf(sourceTypeDefinition, ofTypeNode);
86
+ }
87
+ function checkNot(filterContext, filter, filteredOperands) {
88
+ const operandA = evaluateOperand(filterContext, filter, filteredOperands[0], _coerceToBoolean);
89
+ return !operandA;
90
+ }
91
+ function checkOr(filterContext, filter, filteredOperands) {
92
+ const operandA = evaluateOperand(filterContext, filter, filteredOperands[0], _coerceToBoolean);
93
+ const operandB = evaluateOperand(filterContext, filter, filteredOperands[1], _coerceToBoolean);
94
+ return operandA || operandB;
95
+ }
96
+ /**
97
+ *
98
+ * TRUE if operand[0] and operand[1] are TRUE.
99
+ * The following restrictions apply to the operands:
100
+ * [0]: Any operand that resolves to a Boolean.
101
+ *
102
+ * [1]: Any operand that resolves to a Boolean.
103
+ * If any operand cannot be resolved to a Boolean it is considered a NULL. See below for a discussion on the handling of NULL.
104
+ */
105
+ function checkAnd(filterContext, filter, filteredOperands) {
106
+ const operandA = evaluateOperand(filterContext, filter, filteredOperands[0], _coerceToBoolean);
107
+ const operandB = evaluateOperand(filterContext, filter, filteredOperands[1], _coerceToBoolean);
108
+ return operandA && operandB;
109
+ }
110
+ function checkLessThan(filterContext, filter, filteredOperands) {
111
+ const operandA = evaluateOperand(filterContext, filter, filteredOperands[0], _coerceToNumber);
112
+ const operandB = evaluateOperand(filterContext, filter, filteredOperands[1], _coerceToNumber);
113
+ return operandA < operandB;
114
+ }
115
+ function checkLessThanOrEqual(filterContext, filter, filteredOperands) {
116
+ const operandA = evaluateOperand(filterContext, filter, filteredOperands[0], _coerceToNumber);
117
+ const operandB = evaluateOperand(filterContext, filter, filteredOperands[1], _coerceToNumber);
118
+ return operandA <= operandB;
119
+ }
120
+ function checkGreaterThan(filterContext, filter, filteredOperands) {
121
+ const operandA = evaluateOperand(filterContext, filter, filteredOperands[0], _coerceToNumber);
122
+ const operandB = evaluateOperand(filterContext, filter, filteredOperands[1], _coerceToNumber);
123
+ return operandA > operandB;
124
+ }
125
+ function checkGreaterThanOrEqual(filterContext, filter, filteredOperands) {
126
+ const operandA = evaluateOperand(filterContext, filter, filteredOperands[0], _coerceToNumber);
127
+ const operandB = evaluateOperand(filterContext, filter, filteredOperands[1], _coerceToNumber);
128
+ return operandA >= operandB;
129
+ }
130
+ function checkEquals(filterContext, filter, filteredOperands) {
131
+ const operandA = evaluateOperand(filterContext, filter, filteredOperands[0], _coerceToNumber);
132
+ const operandB = evaluateOperand(filterContext, filter, filteredOperands[1], _coerceToNumber);
133
+ return operandA === operandB;
134
+ }
135
+ /**
136
+ *
137
+ * TRUE if operand[0] is greater or equal to operand[1] and less than or equal to operand[2].
138
+ * The following restrictions apply to the operands:
139
+ * [0]: Any operand that resolves to an ordered value.
140
+ * [1]: Any operand that resolves to an ordered value.
141
+ * [2]: Any operand that resolves to an ordered value.
142
+ * If the operands are of different types, the system shall perform any implicit conversion to match
143
+ * all operands to a common type. If no implicit conversion is available and the operands are of different
144
+ * types, the particular result is FALSE. See the discussion on data type precedence in Table 123
145
+ * for more information how to convert operands of different types.
146
+ */
147
+ function checkBetween(filterContext, filter, filteredOperands) {
148
+ const operandA = evaluateOperand(filterContext, filter, filteredOperands[0], _coerceToNumber);
149
+ const operandLow = evaluateOperand(filterContext, filter, filteredOperands[1], _coerceToNumber);
150
+ const operandHigh = evaluateOperand(filterContext, filter, filteredOperands[2], _coerceToNumber);
151
+ return operandA >= operandLow && operandA <= operandHigh;
152
+ }
153
+ /**
154
+ *
155
+ * InList
156
+ * TRUE if operand[0] is equal to one or more of the remaining operands.
157
+ * The Equals Operator is evaluated for operand[0] and each remaining operand in the
158
+ * list. If any Equals evaluation is TRUE, InList returns TRUE
159
+ x*/
160
+ function checkInList(context, filterOperands) {
161
+ const operand0 = filterOperands[0];
162
+ // istanbul ignore next
163
+ if (!(operand0 instanceof node_opcua_types_1.SimpleAttributeOperand)) {
164
+ // unsupported case
165
+ warningLog("FilterOperator.InList operand0 is not a SimpleAttributeOperand " + operand0.constructor.name);
166
+ return false;
167
+ }
168
+ const value = (0, resolve_operand_1.resolveOperand)(context, operand0);
169
+ // istanbul ignore next
170
+ if (value.dataType !== node_opcua_variant_1.DataType.NodeId) {
171
+ return false;
172
+ }
173
+ const nodeId = value.value;
174
+ // istanbul ignore next
175
+ if (!nodeId) {
176
+ return false;
177
+ }
178
+ function _is(nodeId1, operandX) {
179
+ if (operandX.value.dataType !== node_opcua_variant_1.DataType.NodeId) {
180
+ return false;
181
+ }
182
+ const nodeId2 = operandX.value.value;
183
+ const nodeClass = context.getNodeClass(nodeId2);
184
+ if (nodeClass === node_opcua_data_model_1.NodeClass.Unspecified) {
185
+ return false;
186
+ }
187
+ return (0, node_opcua_nodeid_1.sameNodeId)(nodeId1, nodeId2);
188
+ }
189
+ for (let i = 1; i < filterOperands.length; i++) {
190
+ const filterOperand = filterOperands[i];
191
+ if (filterOperand instanceof node_opcua_types_1.LiteralOperand && _is(nodeId, filterOperand)) {
192
+ return true;
193
+ }
194
+ }
195
+ return false;
196
+ }
197
+ // eslint-disable-next-line complexity
198
+ function checkFilterAtIndex(filterContext, filter, index) {
199
+ if (!filter.elements || filter.elements.length === 0) {
200
+ return true;
201
+ }
202
+ const element = filter.elements[index];
203
+ // istanbul ignore next
204
+ if (!element) {
205
+ return true;
206
+ }
207
+ const filterOperands = element.filterOperands || [];
208
+ switch (element.filterOperator) {
209
+ case node_opcua_types_1.FilterOperator.Equals:
210
+ return checkEquals(filterContext, filter, filterOperands);
211
+ case node_opcua_types_1.FilterOperator.LessThan:
212
+ return checkLessThan(filterContext, filter, filterOperands);
213
+ case node_opcua_types_1.FilterOperator.LessThanOrEqual:
214
+ return checkLessThanOrEqual(filterContext, filter, filterOperands);
215
+ case node_opcua_types_1.FilterOperator.GreaterThan:
216
+ return checkGreaterThan(filterContext, filter, filterOperands);
217
+ case node_opcua_types_1.FilterOperator.GreaterThanOrEqual:
218
+ return checkGreaterThanOrEqual(filterContext, filter, filterOperands);
219
+ case node_opcua_types_1.FilterOperator.Between:
220
+ return checkBetween(filterContext, filter, filterOperands);
221
+ case node_opcua_types_1.FilterOperator.And:
222
+ return checkAnd(filterContext, filter, filterOperands);
223
+ case node_opcua_types_1.FilterOperator.Or:
224
+ return checkOr(filterContext, filter, filterOperands);
225
+ case node_opcua_types_1.FilterOperator.Not:
226
+ return checkNot(filterContext, filter, filterOperands);
227
+ case node_opcua_types_1.FilterOperator.OfType:
228
+ return checkOfType(filterContext, element.filterOperands[0]);
229
+ case node_opcua_types_1.FilterOperator.InList:
230
+ return checkInList(filterContext, filterOperands);
231
+ case node_opcua_types_1.FilterOperator.RelatedTo:
232
+ case node_opcua_types_1.FilterOperator.Like:
233
+ case node_opcua_types_1.FilterOperator.BitwiseAnd:
234
+ case node_opcua_types_1.FilterOperator.BitwiseOr:
235
+ case node_opcua_types_1.FilterOperator.Cast:
236
+ case node_opcua_types_1.FilterOperator.InView:
237
+ case node_opcua_types_1.FilterOperator.IsNull:
238
+ default:
239
+ // from Spec OPC Unified Architecture, Part 4 133 Release 1.04
240
+ // Any basic FilterOperator in Table 119 may be used in the whereClause, however, only the
241
+ // OfType_14 FilterOperator from Table 120 is permitted.
242
+ warningLog(`checkFilter: operator ${node_opcua_types_1.FilterOperator[element.filterOperator]} is currently not supported in filter`);
243
+ return false;
244
+ }
245
+ }
246
+ function checkFilter(filterContext, contentFilter) {
247
+ return checkFilterAtIndex(filterContext, contentFilter, 0);
248
+ }
249
+ exports.checkFilter = checkFilter;
250
+ //# sourceMappingURL=check_where_clause.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check_where_clause.js","sourceRoot":"","sources":["../source/check_where_clause.ts"],"names":[],"mappings":";;;AAAA,uDAQ0B;AAE1B,2DAAuD;AACvD,iEAAkD;AAClD,yDAAuD;AACvD,uDAAmD;AAGnD,uDAAmD;AAEnD,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,QAAQ,CAAC,CAAC;AAE7C,SAAS,gBAAgB,CAAC,KAAiD;IACvE,IAAI,KAAK,YAAY,4BAAO,EAAE;QAC1B,OAAO,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACxC;IACD,OAAO,CAAC,CAAC,KAAK,CAAC;AACnB,CAAC;AACD,SAAS,eAAe,CAAC,KAAiD;IACtE,IAAI,KAAK,YAAY,4BAAO,EAAE;QAC1B,OAAO,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACvC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;KAC9B;IACD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QAC5B,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACxB;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,CAAC,CAAC;AACb,CAAC;AAED,SAAS,eAAe,CACpB,aAA4B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AAE,aAA4B;IAClF,OAAO,kBAAkB,CAAC,aAAa,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAFD,kCAEC"}
@@ -0,0 +1,9 @@
1
+ import { SimpleAttributeOperand } from "node-opcua-types";
2
+ import { Variant } from "node-opcua-variant";
3
+ import { FilterContext } from "./filter_context";
4
+ /**
5
+ *
6
+ * extract a eventField from a event node, matching the given selectClause
7
+ */
8
+ export declare function extractEventField(context: FilterContext, operand: SimpleAttributeOperand): Variant;
9
+ export declare function extractEventFieldsBase(context: FilterContext, selectClauses: SimpleAttributeOperand[]): Variant[];
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractEventFieldsBase = exports.extractEventField = void 0;
4
+ const node_opcua_assert_1 = require("node-opcua-assert");
5
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
6
+ const node_opcua_debug_1 = require("node-opcua-debug");
7
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
8
+ const node_opcua_types_1 = require("node-opcua-types");
9
+ const node_opcua_variant_1 = require("node-opcua-variant");
10
+ const resolve_operand_1 = require("./resolve_operand");
11
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)("FILTER");
12
+ const conditionTypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("ConditionType");
13
+ /**
14
+ *
15
+ * extract a eventField from a event node, matching the given selectClause
16
+ */
17
+ function extractEventField(context, operand) {
18
+ (0, node_opcua_assert_1.assert)(operand instanceof node_opcua_types_1.SimpleAttributeOperand);
19
+ operand.browsePath = operand.browsePath || [];
20
+ if (operand.browsePath.length === 0 && operand.attributeId === node_opcua_data_model_1.AttributeIds.NodeId) {
21
+ // "ns=0;i=2782" => ConditionType
22
+ // "ns=0;i=2041" => BaseEventType
23
+ if (!(0, node_opcua_nodeid_1.sameNodeId)(operand.typeDefinitionId, conditionTypeNodeId)) {
24
+ // not a ConditionType
25
+ // but could be on of its derived type. for instance ns=0;i=2881 => AcknowledgeableConditionType
26
+ if (!context.isSubtypeOf(operand.typeDefinitionId, conditionTypeNodeId)) {
27
+ warningLog(" ", operand.typeDefinitionId.toString());
28
+ warningLog("this case is not handled yet : selectClause.typeDefinitionId = " + operand.typeDefinitionId.toString());
29
+ warningLog(operand.toString());
30
+ return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.NodeId, value: context.eventSource });
31
+ }
32
+ }
33
+ const eventSourceTypeDefinition = context.getTypeDefinition(context.eventSource);
34
+ if (!eventSourceTypeDefinition) {
35
+ // eventSource is a EventType class
36
+ return new node_opcua_variant_1.Variant();
37
+ }
38
+ if (!context.isSubtypeOf(eventSourceTypeDefinition, conditionTypeNodeId)) {
39
+ return new node_opcua_variant_1.Variant();
40
+ }
41
+ // Yeh : our EventType is a Condition Type !
42
+ return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.NodeId, value: context.eventSource });
43
+ }
44
+ return (0, resolve_operand_1.resolveOperand)(context, operand);
45
+ }
46
+ exports.extractEventField = extractEventField;
47
+ function extractEventFieldsBase(context, selectClauses) {
48
+ (0, node_opcua_assert_1.assert)(Array.isArray(selectClauses));
49
+ (0, node_opcua_assert_1.assert)(selectClauses.length === 0 || selectClauses[0] instanceof node_opcua_types_1.SimpleAttributeOperand);
50
+ return selectClauses.map(extractEventField.bind(null, context));
51
+ }
52
+ exports.extractEventFieldsBase = extractEventFieldsBase;
53
+ //# sourceMappingURL=extract_event_field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract_event_field.js","sourceRoot":"","sources":["../source/extract_event_field.ts"],"names":[],"mappings":";;;AAAA,yDAA2C;AAC3C,iEAAqD;AACrD,uDAAmD;AACnD,yDAAsE;AACtE,uDAA0D;AAC1D,2DAAuD;AAEvD,uDAAmD;AAEnD,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,QAAQ,CAAC,CAAC;AAC7C,MAAM,mBAAmB,GAAG,IAAA,iCAAa,EAAC,eAAe,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BAAO,CAAC,EAAE,QAAQ,EAAE,6BAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;KACjF;IACD,OAAO,IAAA,gCAAc,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAhCD,8CAgCC;AAED,SAAgB,sBAAsB,CAAC,OAAsB,EAAE,aAAuC;IAClG,IAAA,0BAAM,EAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IACrC,IAAA,0BAAM,EAAC,aAAa,CAAC,MAAM,KAAK,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,YAAY,yCAAsB,CAAC,CAAC;IACzF,OAAO,aAAa,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAJD,wDAIC"}
@@ -0,0 +1,11 @@
1
+ import { NodeId, NodeIdLike } from "node-opcua-nodeid";
2
+ import { BrowsePath, NodeClass } from "node-opcua-types";
3
+ import { Variant } from "node-opcua-variant";
4
+ export interface FilterContext {
5
+ readonly eventSource: NodeId;
6
+ isSubtypeOf(nodeId: NodeId, baseType: NodeId): boolean;
7
+ getTypeDefinition(nodeId: NodeId): NodeId | null;
8
+ readNodeValue(nodeId: NodeIdLike): Variant;
9
+ getNodeClass(nodeId: NodeId): NodeClass;
10
+ browsePath(browsePath: BrowsePath): NodeId | null;
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=filter_context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter_context.js","sourceRoot":"","sources":["../source/filter_context.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  /**
2
2
  * @module node-opcua-service-filter
3
3
  */
4
+ export * from "./check_event_clause";
5
+ export * from "./check_where_clause";
6
+ export * from "./extract_event_field";
7
+ export * from "./filter_context";
4
8
  export * from "./imports";
9
+ export * from "./make_content_filter";
10
+ export * from "./on_address_space/extract_event_fields";
11
+ export * from "./resolve_operand";
5
12
  export * from "./tools_event_filter";
13
+ export * from "./on_address_space/filter_context_on_address_space";
package/dist/index.js CHANGED
@@ -17,8 +17,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  /**
18
18
  * @module node-opcua-service-filter
19
19
  */
20
+ __exportStar(require("./check_event_clause"), exports);
21
+ __exportStar(require("./check_where_clause"), exports);
22
+ __exportStar(require("./extract_event_field"), exports);
23
+ __exportStar(require("./filter_context"), exports);
20
24
  __exportStar(require("./imports"), exports);
25
+ __exportStar(require("./make_content_filter"), exports);
26
+ __exportStar(require("./on_address_space/extract_event_fields"), exports);
27
+ __exportStar(require("./resolve_operand"), exports);
21
28
  __exportStar(require("./tools_event_filter"), exports);
29
+ __exportStar(require("./on_address_space/filter_context_on_address_space"), exports);
22
30
  // The SimpleAttributeOperand is a simplified form of the AttributeOperand and all of the rules that
23
31
  // apply to the AttributeOperand also apply to the SimpleAttributeOperand. The examples provided in
24
32
  // B.1 only use AttributeOperand, however, the AttributeOperand can be replaced by a
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,4CAA0B;AAC1B,uDAAqC;AAErC,oGAAoG;AACpG,mGAAmG;AACnG,oFAAoF;AACpF,yFAAyF;AACzF,mGAAmG;AAEnG,mBAAmB;AACnB,iFAAiF;AACjF,uBAAuB;AACvB,mGAAmG;AAEnG,aAAa;AACb,6BAA6B;AAC7B,kFAAkF;AAClF,uEAAuE;AACvE,gFAAgF;AAChF,kEAAkE;AAClE,2EAA2E;AAC3E,YAAY;AACZ,wEAAwE;AACxE,mEAAmE;AAEnE,yDAAyD;AACzD,8EAA8E;AAC9E,4EAA4E;AAC5E,iBAAiB;AACjB,iDAAiD;AAEjD,qFAAqF;AACrF,8EAA8E;AAC9E,qFAAqF;AACrF,4BAA4B;AAC5B,0CAA0C;AAC1C,uEAAuE;AACvE,4CAA4C;AAC5C,kDAAkD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,uDAAqC;AACrC,uDAAqC;AACrC,wDAAsC;AACtC,mDAAiC;AACjC,4CAA0B;AAC1B,wDAAsC;AACtC,0EAAwD;AACxD,oDAAkC;AAClC,uDAAqC;AACrC,qFAAmE;AAEnE,oGAAoG;AACpG,mGAAmG;AACnG,oFAAoF;AACpF,yFAAyF;AACzF,mGAAmG;AAEnG,mBAAmB;AACnB,iFAAiF;AACjF,uBAAuB;AACvB,mGAAmG;AAEnG,aAAa;AACb,6BAA6B;AAC7B,kFAAkF;AAClF,uEAAuE;AACvE,gFAAgF;AAChF,kEAAkE;AAClE,2EAA2E;AAC3E,YAAY;AACZ,wEAAwE;AACxE,mEAAmE;AAEnE,yDAAyD;AACzD,8EAA8E;AAC9E,4EAA4E;AAC5E,iBAAiB;AACjB,iDAAiD;AAEjD,qFAAqF;AACrF,8EAA8E;AAC9E,qFAAqF;AACrF,4BAA4B;AAC5B,0CAA0C;AAC1C,uEAAuE;AACvE,4CAA4C;AAC5C,kDAAkD"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @module node-opcua-service-filter
3
+ */
4
+ import { DataType } from "node-opcua-basic-types";
5
+ import { AttributeIds } from "node-opcua-data-model";
6
+ import { NodeIdLike } from "node-opcua-nodeid";
7
+ import { AttributeOperand, ContentFilter, ContentFilterElement, ContentFilterElementOptions, LiteralOperand, SimpleAttributeOperand } from "./imports";
8
+ export declare function ofType(nodeId: NodeIdLike): ContentFilterElement;
9
+ export declare function l(dataType: DataType, value: any): LiteralOperand;
10
+ export declare function n(n: NodeIdLike): LiteralOperand;
11
+ export declare function s(attributeId: AttributeIds, path: string): SimpleAttributeOperand;
12
+ declare type A = LiteralOperand | SimpleAttributeOperand | AttributeOperand | ContentFilterElement;
13
+ export declare function or(a: A, b: A): ContentFilterElement;
14
+ export declare function and(a: A, b: A): ContentFilterElement;
15
+ export declare function lessThan(a: A, b: A): ContentFilterElement;
16
+ export declare function LessThanOrEqual(a: A, b: A): ContentFilterElement;
17
+ export declare function greaterThanOrEqual(a: A, b: A): ContentFilterElement;
18
+ export declare function greaterThan(a: A, b: A): ContentFilterElement;
19
+ export declare function inList(a: A, l: A[]): ContentFilterElement;
20
+ export declare function makeContentFilterElements(o: ContentFilterElement): ContentFilterElement[];
21
+ export declare function makeContentFilter(o: ContentFilterElementOptions): ContentFilter;
22
+ export {};
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeContentFilter = exports.makeContentFilterElements = exports.inList = exports.greaterThan = exports.greaterThanOrEqual = exports.LessThanOrEqual = exports.lessThan = exports.and = exports.or = exports.s = exports.n = exports.l = exports.ofType = void 0;
4
+ /**
5
+ * @module node-opcua-service-filter
6
+ */
7
+ const node_opcua_basic_types_1 = require("node-opcua-basic-types");
8
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
9
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
10
+ const node_opcua_variant_1 = require("node-opcua-variant");
11
+ const imports_1 = require("./imports");
12
+ function ofType(nodeId) {
13
+ const element = new imports_1.ContentFilterElement({
14
+ filterOperator: imports_1.FilterOperator.OfType,
15
+ filterOperands: [
16
+ new imports_1.LiteralOperand({
17
+ value: {
18
+ dataType: node_opcua_basic_types_1.DataType.NodeId,
19
+ value: (0, node_opcua_nodeid_1.resolveNodeId)(nodeId)
20
+ }
21
+ })
22
+ ]
23
+ });
24
+ return element;
25
+ }
26
+ exports.ofType = ofType;
27
+ function l(dataType, value) {
28
+ switch (dataType) {
29
+ case node_opcua_basic_types_1.DataType.NodeId:
30
+ value = (0, node_opcua_nodeid_1.resolveNodeId)(value);
31
+ }
32
+ return new imports_1.LiteralOperand({ value: new node_opcua_variant_1.Variant({ dataType, value }) });
33
+ }
34
+ exports.l = l;
35
+ function n(n) {
36
+ return l(node_opcua_basic_types_1.DataType.NodeId, n);
37
+ }
38
+ exports.n = n;
39
+ function s(attributeId, path) {
40
+ return new imports_1.SimpleAttributeOperand({
41
+ attributeId: attributeId,
42
+ browsePath: path.split(".").map(node_opcua_data_model_1.coerceQualifiedName)
43
+ });
44
+ }
45
+ exports.s = s;
46
+ function or(a, b) {
47
+ return new imports_1.ContentFilterElement({
48
+ filterOperands: [a, b],
49
+ filterOperator: imports_1.FilterOperator.Or
50
+ });
51
+ }
52
+ exports.or = or;
53
+ function and(a, b) {
54
+ return new imports_1.ContentFilterElement({
55
+ filterOperands: [a, b],
56
+ filterOperator: imports_1.FilterOperator.And
57
+ });
58
+ }
59
+ exports.and = and;
60
+ function lessThan(a, b) {
61
+ return new imports_1.ContentFilterElement({
62
+ filterOperands: [a, b],
63
+ filterOperator: imports_1.FilterOperator.LessThan
64
+ });
65
+ }
66
+ exports.lessThan = lessThan;
67
+ function LessThanOrEqual(a, b) {
68
+ return new imports_1.ContentFilterElement({
69
+ filterOperands: [a, b],
70
+ filterOperator: imports_1.FilterOperator.LessThanOrEqual
71
+ });
72
+ }
73
+ exports.LessThanOrEqual = LessThanOrEqual;
74
+ function greaterThanOrEqual(a, b) {
75
+ return new imports_1.ContentFilterElement({
76
+ filterOperands: [a, b],
77
+ filterOperator: imports_1.FilterOperator.GreaterThanOrEqual
78
+ });
79
+ }
80
+ exports.greaterThanOrEqual = greaterThanOrEqual;
81
+ function greaterThan(a, b) {
82
+ return new imports_1.ContentFilterElement({
83
+ filterOperands: [a, b],
84
+ filterOperator: imports_1.FilterOperator.GreaterThan
85
+ });
86
+ }
87
+ exports.greaterThan = greaterThan;
88
+ function inList(a, l) {
89
+ return new imports_1.ContentFilterElement({
90
+ filterOperands: [a, ...l],
91
+ filterOperator: imports_1.FilterOperator.InList
92
+ });
93
+ }
94
+ exports.inList = inList;
95
+ function makeContentFilterElements(o) {
96
+ const elements = [];
97
+ function pushElement(element) {
98
+ elements.push(element);
99
+ const thisIndex = elements.length - 1;
100
+ if (element.filterOperands) {
101
+ for (let i = 0; i < element.filterOperands.length; i++) {
102
+ const op = element.filterOperands[i];
103
+ if (op instanceof imports_1.ContentFilterElement) {
104
+ const index = pushElement(op);
105
+ element.filterOperands[i] = new imports_1.ElementOperand({ index });
106
+ }
107
+ }
108
+ }
109
+ return thisIndex;
110
+ }
111
+ pushElement(o);
112
+ return elements;
113
+ }
114
+ exports.makeContentFilterElements = makeContentFilterElements;
115
+ function makeContentFilter(o) {
116
+ return new imports_1.ContentFilter({
117
+ elements: makeContentFilterElements(o instanceof imports_1.ContentFilterElement ? o : new imports_1.ContentFilterElement(o))
118
+ });
119
+ }
120
+ exports.makeContentFilter = makeContentFilter;
121
+ //# sourceMappingURL=make_content_filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make_content_filter.js","sourceRoot":"","sources":["../source/make_content_filter.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mEAAkD;AAElD,iEAAgH;AAChH,yDAA8D;AAE9D,2DAA6C;AAE7C,uCAWmB;AAEnB,SAAgB,MAAM,CAAC,MAAkB;IACrC,MAAM,OAAO,GAAyB,IAAI,8BAAoB,CAAC;QAC3D,cAAc,EAAE,wBAAc,CAAC,MAAM;QACrC,cAAc,EAAE;YACZ,IAAI,wBAAc,CAAC;gBACf,KAAK,EAAE;oBACH,QAAQ,EAAE,iCAAQ,CAAC,MAAM;oBACzB,KAAK,EAAE,IAAA,iCAAa,EAAC,MAAM,CAAC;iBAC/B;aACJ,CAAC;SACL;KACJ,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACnB,CAAC;AAbD,wBAaC;AAED,SAAgB,CAAC,CAAC,QAAkB,EAAE,KAAU;IAC5C,QAAQ,QAAQ,EAAE;QACd,KAAK,iCAAQ,CAAC,MAAM;YAChB,KAAK,GAAG,IAA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AG,WAAW,CAAC,EAAE,CAAC,CAAC;oBAC9B,OAAO,CAAC,cAAe,CAAC,CAAC,CAAC,GAAG,IAAI,wBAAc,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC9D;aACJ;SACJ;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,WAAW,CAAC,CAAC,CAAC,CAAC;IAEf,OAAO,QAAQ,CAAC;AACpB,CAAC;AApBD,8DAoBC;AAED,SAAgB,iBAAiB,CAAC,CAA8B;IAC5D,OAAO,IAAI,uBAAa,CAAC;QACrB,QAAQ,EAAE,yBAAyB,CAAC,CAAC,YAAY,8BAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,8BAAoB,CAAC,CAAC,CAAC,CAAC;KAC3G,CAAC,CAAC;AACP,CAAC;AAJD,8CAIC"}
@@ -0,0 +1,10 @@
1
+ import { IEventData, ISessionContext } from "node-opcua-address-space-base";
2
+ import { SimpleAttributeOperand } from "node-opcua-types";
3
+ import { Variant } from "node-opcua-variant";
4
+ /**
5
+ * @method extractEventFields
6
+ * extract a array of eventFields from a event node, matching the selectClauses
7
+ * @param selectClauses
8
+ * @param eventData : a pseudo Node that provides a browse Method and a readValue(nodeId)
9
+ */
10
+ export declare function extractEventFields(sessionContext: ISessionContext, selectClauses: SimpleAttributeOperand[], eventData: IEventData): Variant[];