Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-opcua-service-filter

Package Overview
Dependencies
Maintainers
1
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-service-filter - npm Package Compare versions

Comparing version 2.74.0 to 2.75.0

dist/check_event_clause.d.ts

8

dist/index.d.ts
/**
* @module node-opcua-service-filter
*/
export * from "./check_event_clause";
export * from "./check_where_clause";
export * from "./extract_event_field";
export * from "./filter_context";
export * from "./imports";
export * from "./make_content_filter";
export * from "./on_address_space/extract_event_fields";
export * from "./resolve_operand";
export * from "./tools_event_filter";
export * from "./on_address_space/filter_context_on_address_space";

@@ -20,4 +20,12 @@ "use strict";

*/
__exportStar(require("./check_event_clause"), exports);
__exportStar(require("./check_where_clause"), exports);
__exportStar(require("./extract_event_field"), exports);
__exportStar(require("./filter_context"), exports);
__exportStar(require("./imports"), exports);
__exportStar(require("./make_content_filter"), exports);
__exportStar(require("./on_address_space/extract_event_fields"), exports);
__exportStar(require("./resolve_operand"), exports);
__exportStar(require("./tools_event_filter"), exports);
__exportStar(require("./on_address_space/filter_context_on_address_space"), exports);
// The SimpleAttributeOperand is a simplified form of the AttributeOperand and all of the rules that

@@ -24,0 +32,0 @@ // apply to the AttributeOperand also apply to the SimpleAttributeOperand. The examples provided in

20

dist/tools_event_filter.d.ts

@@ -0,10 +1,8 @@

import { ContentFilterElement, ContentFilterOptions, EventFilter, SimpleAttributeOperand } from "./imports";
export declare function constructSelectClause(arrayOfNames: string | string[]): SimpleAttributeOperand[];
/**
* @module node-opcua-service-filter
*/
import { NodeId } from "node-opcua-nodeid";
import { EventFilter, SimpleAttributeOperand } from "./imports";
/**
* helper to construct event filters:
* construct a simple event filter
*
* "ConditionId" in the arrayOfNames has a special meaning
*

@@ -22,12 +20,2 @@ * @example

*/
export declare function constructEventFilter(arrayOfNames: string[] | string, conditionTypes?: NodeId[] | NodeId): EventFilter;
/**
* @class SimpleAttributeOperand
* @method toShortString
* @return {String}
*
* @example:
*
*
*/
export declare function simpleAttributeOperandToShortString(self: SimpleAttributeOperand, addressSpace: any): string;
export declare function constructEventFilter(arrayOfNames: string[] | string, whereClause?: ContentFilterOptions | ContentFilterElement): EventFilter;

174

dist/tools_event_filter.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.constructEventFilter = exports.constructSelectClause = void 0;
/**
* @module node-opcua-service-filter
*/
// tslint:disable:object-literal-shorthand
// tslint:disable:only-arrow-functions
// tslint:disable:max-line-length
Object.defineProperty(exports, "__esModule", { value: true });
exports.simpleAttributeOperandToShortString = exports.constructEventFilter = void 0;
const node_opcua_constants_1 = require("node-opcua-constants");
const node_opcua_data_model_1 = require("node-opcua-data-model");
const node_opcua_debug_1 = require("node-opcua-debug");
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
const imports_1 = require("./imports");
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
/**
* helper to construct event filters:
* construct a simple event filter
*
*
* @example
*
* constructEventFilter(["SourceName","Message","ReceiveTime"]);
*
* constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
* constructEventFilter(["SourceName","2:MyData" ]);
*
* constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
* constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
*
*/
function constructEventFilter(arrayOfNames, conditionTypes) {
function constructSelectClause(arrayOfNames) {
if (!Array.isArray(arrayOfNames)) {
return constructEventFilter([arrayOfNames], conditionTypes);
return constructSelectClause([arrayOfNames]);
}
if (conditionTypes && !Array.isArray(conditionTypes)) {
return constructEventFilter(arrayOfNames, [conditionTypes]);
}
// istanbul ignore next
if (!(arrayOfNames instanceof Array)) {
throw new Error("internal error");
}
// replace "string" element in the form A.B.C into [ "A","B","C"]
const arrayOfNames2 = arrayOfNames.map((path) => {
if (typeof path !== "string") {
return path;
}
return path.split(".");
});
const arrayOfNames3 = arrayOfNames2.map((path) => {
if (Array.isArray(path)) {
return path.map(node_opcua_data_model_1.stringToQualifiedName);
}
return path;
});
const arrayOfNames2 = arrayOfNames.map((path) => (typeof path !== "string" ? path : path.split(".")));
const arrayOfNames3 = arrayOfNames2.map((path) => (Array.isArray(path) ? path.map(node_opcua_data_model_1.stringToQualifiedName) : path));
// replace "string" elements in arrayOfName with QualifiedName in namespace 0
const arrayOfNames4 = arrayOfNames3.map((s) => {
return typeof s === "string" ? (0, node_opcua_data_model_1.stringToQualifiedName)(s) : s;
});
const arrayOfNames4 = arrayOfNames3.map((s) => (typeof s === "string" ? (0, node_opcua_data_model_1.stringToQualifiedName)(s) : s));
// construct browse paths array
const browsePaths = arrayOfNames4.map((s) => {
return Array.isArray(s) ? s : [s];
});
const browsePaths = arrayOfNames4.map((s) => (Array.isArray(s) ? s : [s]));
// Part 4 page 127:
// In some cases the same BrowsePath will apply to multiple EventTypes. If the Client specifies the BaseEventType
// in the SimpleAttributeOperand then the Server shall evaluate the BrowsePath without considering the Type.
const isBrowsePathForConditionId = (browsePath) => browsePath.length === 1 && browsePath[0].namespaceIndex === 0 && browsePath[0].name === "ConditionId";
// [..]

@@ -72,88 +29,63 @@ // The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only

// That said, profiles defined in Part 7 may make support for additional Attributes mandatory.
let selectClauses = browsePaths.map((browsePath) => {
return new imports_1.SimpleAttributeOperand({
attributeId: node_opcua_data_model_1.AttributeIds.Value,
browsePath,
indexRange: undefined,
typeDefinitionId: (0, node_opcua_nodeid_1.makeNodeId)(node_opcua_constants_1.ObjectTypeIds.BaseEventType) // i=2041
});
});
if (conditionTypes && conditionTypes instanceof Array) {
const extraSelectClauses = conditionTypes.map((nodeId) => {
const selectClauses = browsePaths.map((browsePath) => {
if (isBrowsePathForConditionId(browsePath)) {
// special case
//
// The NodeId of the Condition instance is used as ConditionId. It is not explicitly modelled as a
// component of the ConditionType. However, it can be requested with the following
// SimpleAttributeOperand (see Table 10) in the SelectClause of the EventFilter:
//
// SimpleAttributeOperand
// Name Type Description
// typeId NodeId NodeId of the ConditionType Node
// browsePath[] QualifiedName empty
// attributeId IntegerId Id of the NodeId Attribute
//
return new imports_1.SimpleAttributeOperand({
attributeId: node_opcua_data_model_1.AttributeIds.NodeId,
browsePath: undefined,
browsePath: null,
indexRange: undefined,
typeDefinitionId: nodeId // conditionType for instance
typeDefinitionId: node_opcua_constants_1.ObjectTypeIds.ConditionType // i=2782
});
});
selectClauses = selectClauses.concat(extraSelectClauses);
}
const filter = new imports_1.EventFilter({
selectClauses,
whereClause: {
// ContentFilter
elements: [
// ContentFilterElement
// {
// filterOperator: FilterOperator.IsNull,
// filterOperands: [ //
// new ElementOperand({
// index: 123
// }),
// new AttributeOperand({
// nodeId: "i=10",
// alias: "someText",
// browsePath: { //RelativePath
//
// },
// attributeId: AttributeIds.Value
// })
// ]
// }
]
}
else
return new imports_1.SimpleAttributeOperand({
attributeId: node_opcua_data_model_1.AttributeIds.Value,
browsePath,
indexRange: undefined,
typeDefinitionId: node_opcua_constants_1.ObjectTypeIds.BaseEventType // i=2041
});
});
return filter;
return selectClauses;
}
exports.constructEventFilter = constructEventFilter;
exports.constructSelectClause = constructSelectClause;
/**
* @class SimpleAttributeOperand
* @method toPath
* @return {String}
* helper to construct event filters:
* construct a simple event filter
*
* @example:
* "ConditionId" in the arrayOfNames has a special meaning
*
* @example
*
*/
function simpleAttributeOperandToPath(self) {
if (!self.browsePath) {
return "";
}
return self.browsePath
.map((a) => {
return a.name;
})
.join("/");
}
/**
* @class SimpleAttributeOperand
* @method toShortString
* @return {String}
* constructEventFilter(["SourceName","Message","ReceiveTime"]);
*
* @example:
* constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
* constructEventFilter(["SourceName","2:MyData" ]);
*
* constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
* constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
*
*/
function simpleAttributeOperandToShortString(self, addressSpace // Address Space
) {
let str = "";
if (addressSpace) {
const n = addressSpace.findNode(self.typeDefinitionId);
str += n.BrowseName.toString();
function constructEventFilter(arrayOfNames, whereClause) {
const selectClauses = constructSelectClause(arrayOfNames);
if (whereClause instanceof imports_1.ContentFilterElement) {
whereClause = new imports_1.ContentFilter({ elements: [whereClause] });
}
str += "[" + self.typeDefinitionId.toString() + "]" + simpleAttributeOperandToPath(self);
return str;
const filter = new imports_1.EventFilter({
selectClauses,
whereClause
});
return filter;
}
exports.simpleAttributeOperandToShortString = simpleAttributeOperandToShortString;
exports.constructEventFilter = constructEventFilter;
//# sourceMappingURL=tools_event_filter.js.map
{
"name": "node-opcua-service-filter",
"version": "2.74.0",
"version": "2.75.0",
"description": "pure nodejs OPCUA SDK - module -service-filter",

@@ -13,2 +13,3 @@ "main": "./dist/index.js",

"dependencies": {
"node-opcua-address-space-base": "2.75.0",
"node-opcua-assert": "2.74.0",

@@ -18,14 +19,17 @@ "node-opcua-basic-types": "2.74.0",

"node-opcua-constants": "2.74.0",
"node-opcua-data-model": "2.74.0",
"node-opcua-data-model": "2.75.0",
"node-opcua-data-value": "2.75.0",
"node-opcua-debug": "2.74.0",
"node-opcua-factory": "2.74.0",
"node-opcua-extension-object": "2.75.0",
"node-opcua-factory": "2.75.0",
"node-opcua-nodeid": "2.74.0",
"node-opcua-numeric-range": "2.74.0",
"node-opcua-service-translate-browse-path": "2.74.0",
"node-opcua-numeric-range": "2.75.0",
"node-opcua-packet-analyzer": "2.75.0",
"node-opcua-service-translate-browse-path": "2.75.0",
"node-opcua-status-code": "2.74.0",
"node-opcua-types": "2.74.0",
"node-opcua-variant": "2.74.0"
"node-opcua-types": "2.75.0",
"node-opcua-variant": "2.75.0"
},
"devDependencies": {
"node-opcua-service-secure-channel": "2.74.0",
"node-opcua-service-secure-channel": "2.75.0",
"should": "^13.2.3"

@@ -48,3 +52,3 @@ },

"homepage": "http://node-opcua.github.io/",
"gitHead": "003ee041795f3b737afaaef5721045ee31ea9f77"
"gitHead": "5ccb835ca480c2a8a591ae61b5949a9d8bad4017"
}
/**
* @module node-opcua-service-filter
*/
export * from "./check_event_clause";
export * from "./check_where_clause";
export * from "./extract_event_field";
export * from "./filter_context";
export * from "./imports";
export * from "./make_content_filter";
export * from "./on_address_space/extract_event_fields";
export * from "./resolve_operand";
export * from "./tools_event_filter";
export * from "./on_address_space/filter_context_on_address_space";

@@ -7,0 +15,0 @@ // The SimpleAttributeOperand is a simplified form of the AttributeOperand and all of the rules that

/**
* @module node-opcua-service-filter
*/
// tslint:disable:object-literal-shorthand
// tslint:disable:only-arrow-functions
// tslint:disable:max-line-length
import { assert } from "node-opcua-assert";
import { ObjectTypeIds } from "node-opcua-constants";
import { AttributeIds, stringToQualifiedName } from "node-opcua-data-model";
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
import { makeNodeId, NodeId, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
import { DataType, Variant } from "node-opcua-variant";
import { AttributeIds, QualifiedName, stringToQualifiedName } from "node-opcua-data-model";
import { NodeIdLike, resolveNodeId } from "node-opcua-nodeid";
import { EventFilter, SimpleAttributeOperand } from "./imports";
import { ContentFilter, ContentFilterElement, ContentFilterOptions, EventFilter, FilterOperator, SimpleAttributeOperand } from "./imports";
const debugLog = make_debugLog(__filename);
const doDebug = checkDebugFlag(__filename);
import { ofType } from "./make_content_filter";
/**
* helper to construct event filters:
* construct a simple event filter
*
*
* @example
*
* constructEventFilter(["SourceName","Message","ReceiveTime"]);
*
* constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
* constructEventFilter(["SourceName","2:MyData" ]);
*
* constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
* constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
*
*/
export function constructEventFilter(arrayOfNames: string[] | string, conditionTypes?: NodeId[] | NodeId): EventFilter {
export function constructSelectClause(arrayOfNames: string | string[]): SimpleAttributeOperand[] {
if (!Array.isArray(arrayOfNames)) {
return constructEventFilter([arrayOfNames], conditionTypes);
return constructSelectClause([arrayOfNames]);
}
if (conditionTypes && !Array.isArray(conditionTypes)) {
return constructEventFilter(arrayOfNames, [conditionTypes]);
}
// istanbul ignore next
if (!(arrayOfNames instanceof Array)) {
throw new Error("internal error");
}
// replace "string" element in the form A.B.C into [ "A","B","C"]
const arrayOfNames2 = arrayOfNames.map((path) => {
if (typeof path !== "string") {
return path;
}
return path.split(".");
});
const arrayOfNames2 = arrayOfNames.map((path) => (typeof path !== "string" ? path : path.split(".")));
const arrayOfNames3 = arrayOfNames2.map((path) => {
if (Array.isArray(path)) {
return path.map(stringToQualifiedName);
}
return path;
});
const arrayOfNames3 = arrayOfNames2.map((path) => (Array.isArray(path) ? path.map(stringToQualifiedName) : path));
// replace "string" elements in arrayOfName with QualifiedName in namespace 0
const arrayOfNames4 = arrayOfNames3.map((s) => {
return typeof s === "string" ? stringToQualifiedName(s) : s;
});
const arrayOfNames4 = arrayOfNames3.map((s) => (typeof s === "string" ? stringToQualifiedName(s) : s));
// construct browse paths array
const browsePaths = arrayOfNames4.map((s) => {
return Array.isArray(s) ? s : [s];
});
const browsePaths = arrayOfNames4.map((s) => (Array.isArray(s) ? s : [s]));

@@ -75,2 +32,5 @@ // Part 4 page 127:

const isBrowsePathForConditionId = (browsePath: QualifiedName[]) =>
browsePath.length === 1 && browsePath[0].namespaceIndex === 0 && browsePath[0].name === "ConditionId";
// [..]

@@ -80,91 +40,63 @@ // The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only

// That said, profiles defined in Part 7 may make support for additional Attributes mandatory.
let selectClauses = browsePaths.map((browsePath) => {
return new SimpleAttributeOperand({
attributeId: AttributeIds.Value,
browsePath,
indexRange: undefined, // NumericRange
typeDefinitionId: makeNodeId(ObjectTypeIds.BaseEventType) // i=2041
});
});
if (conditionTypes && conditionTypes instanceof Array) {
const extraSelectClauses = conditionTypes.map((nodeId) => {
const selectClauses = browsePaths.map((browsePath: QualifiedName[]) => {
if (isBrowsePathForConditionId(browsePath)) {
// special case
//
// The NodeId of the Condition instance is used as ConditionId. It is not explicitly modelled as a
// component of the ConditionType. However, it can be requested with the following
// SimpleAttributeOperand (see Table 10) in the SelectClause of the EventFilter:
//
// SimpleAttributeOperand
// Name Type Description
// typeId NodeId NodeId of the ConditionType Node
// browsePath[] QualifiedName empty
// attributeId IntegerId Id of the NodeId Attribute
//
return new SimpleAttributeOperand({
attributeId: AttributeIds.NodeId,
browsePath: undefined,
browsePath: null,
indexRange: undefined, // NumericRange
typeDefinitionId: nodeId // conditionType for instance
typeDefinitionId: ObjectTypeIds.ConditionType // i=2782
});
});
selectClauses = selectClauses.concat(extraSelectClauses);
}
const filter = new EventFilter({
selectClauses,
whereClause: {
// ContentFilter
elements: [
// ContentFilterElement
// {
// filterOperator: FilterOperator.IsNull,
// filterOperands: [ //
// new ElementOperand({
// index: 123
// }),
// new AttributeOperand({
// nodeId: "i=10",
// alias: "someText",
// browsePath: { //RelativePath
//
// },
// attributeId: AttributeIds.Value
// })
// ]
// }
]
}
} else
return new SimpleAttributeOperand({
attributeId: AttributeIds.Value,
browsePath,
indexRange: undefined, // NumericRange
typeDefinitionId: ObjectTypeIds.BaseEventType // i=2041
});
});
return filter;
return selectClauses;
}
/**
* @class SimpleAttributeOperand
* @method toPath
* @return {String}
* helper to construct event filters:
* construct a simple event filter
*
* @example:
* "ConditionId" in the arrayOfNames has a special meaning
*
* @example
*
*/
function simpleAttributeOperandToPath(self: SimpleAttributeOperand): string {
if (!self.browsePath) {
return "";
}
return self.browsePath
.map((a) => {
return a.name;
})
.join("/");
}
/**
* @class SimpleAttributeOperand
* @method toShortString
* @return {String}
* constructEventFilter(["SourceName","Message","ReceiveTime"]);
*
* @example:
* constructEventFilter(["SourceName",{namespaceIndex:2 , "MyData"}]);
* constructEventFilter(["SourceName","2:MyData" ]);
*
* constructEventFilter(["SourceName" ,["EnabledState","EffectiveDisplayName"] ]);
* constructEventFilter(["SourceName" ,"EnabledState.EffectiveDisplayName" ]);
*
*/
export function simpleAttributeOperandToShortString(
self: SimpleAttributeOperand,
addressSpace: any // Address Space
): string {
let str = "";
if (addressSpace) {
const n = addressSpace.findNode(self.typeDefinitionId)!;
str += n.BrowseName.toString();
export function constructEventFilter(
arrayOfNames: string[] | string,
whereClause?: ContentFilterOptions | ContentFilterElement
): EventFilter {
const selectClauses = constructSelectClause(arrayOfNames);
if (whereClause instanceof ContentFilterElement) {
whereClause = new ContentFilter({ elements: [whereClause] });
}
str += "[" + self.typeDefinitionId.toString() + "]" + simpleAttributeOperandToPath(self);
return str;
const filter = new EventFilter({
selectClauses,
whereClause
});
return filter;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc