node-opcua-client-dynamic-extension-object 2.98.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.
- package/dist/convert_data_type_definition_to_structuretype_schema.d.ts +14 -0
- package/dist/convert_data_type_definition_to_structuretype_schema.js +411 -0
- package/dist/convert_data_type_definition_to_structuretype_schema.js.map +1 -0
- package/dist/convert_structuretype_schema_to_structure_definition.d.ts +3 -0
- package/dist/convert_structuretype_schema_to_structure_definition.js +54 -0
- package/dist/convert_structuretype_schema_to_structure_definition.js.map +1 -0
- package/dist/extra_data_type_manager.d.ts +16 -0
- package/dist/extra_data_type_manager.js +79 -0
- package/dist/extra_data_type_manager.js.map +1 -0
- package/dist/get_extension_object_constructor.d.ts +7 -0
- package/dist/get_extension_object_constructor.js +38 -0
- package/dist/get_extension_object_constructor.js.map +1 -0
- package/dist/get_extra_data_type_manager.d.ts +3 -0
- package/dist/get_extra_data_type_manager.js +52 -0
- package/dist/get_extra_data_type_manager.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/populate_data_type_manager.d.ts +3 -0
- package/dist/populate_data_type_manager.js +89 -0
- package/dist/populate_data_type_manager.js.map +1 -0
- package/dist/private/find_encodings.d.ts +4 -0
- package/dist/private/find_encodings.js +56 -0
- package/dist/private/find_encodings.js.map +1 -0
- package/dist/private/populate_data_type_manager_103.d.ts +9 -0
- package/dist/private/populate_data_type_manager_103.js +640 -0
- package/dist/private/populate_data_type_manager_103.js.map +1 -0
- package/dist/private/populate_data_type_manager_104.d.ts +9 -0
- package/dist/private/populate_data_type_manager_104.js +218 -0
- package/dist/private/populate_data_type_manager_104.js.map +1 -0
- package/dist/promote_opaque_structure.d.ts +7 -0
- package/dist/promote_opaque_structure.js +47 -0
- package/dist/promote_opaque_structure.js.map +1 -0
- package/dist/promote_opaque_structure_in_notification_data.d.ts +3 -0
- package/dist/promote_opaque_structure_in_notification_data.js +52 -0
- package/dist/promote_opaque_structure_in_notification_data.js.map +1 -0
- package/dist/resolve_dynamic_extension_object.d.ts +6 -0
- package/dist/resolve_dynamic_extension_object.js +178 -0
- package/dist/resolve_dynamic_extension_object.js.map +1 -0
- package/package.json +22 -18
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getExtensionObjectConstructor = void 0;
|
|
13
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
14
|
+
//
|
|
15
|
+
const get_extra_data_type_manager_1 = require("./get_extra_data_type_manager");
|
|
16
|
+
const populate_data_type_manager_104_1 = require("./private/populate_data_type_manager_104");
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
function getExtensionObjectConstructor(session, dataTypeNodeId) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const extraDataTypeManager = yield (0, get_extra_data_type_manager_1.getExtraDataTypeManager)(session);
|
|
23
|
+
const dataTypeFactory = extraDataTypeManager.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
24
|
+
const structureInfo = dataTypeFactory.getStructureInfoForDataType(dataTypeNodeId);
|
|
25
|
+
if (structureInfo) {
|
|
26
|
+
return structureInfo.constructor;
|
|
27
|
+
}
|
|
28
|
+
const dataValue = yield session.read({
|
|
29
|
+
nodeId: dataTypeNodeId,
|
|
30
|
+
attributeId: node_opcua_data_model_1.AttributeIds.BrowseName
|
|
31
|
+
});
|
|
32
|
+
const browseName = dataValue.value.value;
|
|
33
|
+
yield (0, populate_data_type_manager_104_1.readDataTypeDefinitionAndBuildType)(session, dataTypeNodeId, browseName.name, dataTypeFactory, {});
|
|
34
|
+
return yield extraDataTypeManager.getExtensionObjectConstructorFromDataType(dataTypeNodeId);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.getExtensionObjectConstructor = getExtensionObjectConstructor;
|
|
38
|
+
//# sourceMappingURL=get_extension_object_constructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_extension_object_constructor.js","sourceRoot":"","sources":["../source/get_extension_object_constructor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAoE;AAIpE,EAAE;AACF,+EAAwE;AACxE,6FAA8F;AAE9F;;GAEG;AACH,SAAsB,6BAA6B,CAAC,OAAsB,EAAE,cAAsB;;QAC9F,MAAM,oBAAoB,GAAG,MAAM,IAAA,qDAAuB,EAAC,OAAO,CAAC,CAAC;QAEpE,MAAM,eAAe,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC1F,MAAM,aAAa,GAAG,eAAe,CAAC,2BAA2B,CAAC,cAAc,CAAC,CAAC;QAClF,IAAI,aAAa,EAAE;YACf,OAAO,aAAa,CAAC,WAA4C,CAAC;SACrE;QACD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;YACjC,MAAM,EAAE,cAAc;YACtB,WAAW,EAAE,oCAAY,CAAC,UAAU;SACvC,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,KAAsB,CAAC;QAC1D,MAAM,IAAA,mEAAkC,EAAC,OAAO,EAAE,cAAc,EAAE,UAAU,CAAC,IAAK,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;QAEzG,OAAO,MAAM,oBAAoB,CAAC,yCAAyC,CAAC,cAAc,CAAC,CAAC;IAChG,CAAC;CAAA;AAhBD,sEAgBC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getExtraDataTypeManager = void 0;
|
|
13
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
14
|
+
const node_opcua_factory_1 = require("node-opcua-factory");
|
|
15
|
+
const node_opcua_pseudo_session_1 = require("node-opcua-pseudo-session");
|
|
16
|
+
//
|
|
17
|
+
const extra_data_type_manager_1 = require("./extra_data_type_manager");
|
|
18
|
+
const populate_data_type_manager_1 = require("./populate_data_type_manager");
|
|
19
|
+
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
|
|
20
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
21
|
+
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
22
|
+
function getExtraDataTypeManager(session) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const sessionPriv = session;
|
|
25
|
+
if (!sessionPriv.$$extraDataTypeManager) {
|
|
26
|
+
const dataTypeManager = new extra_data_type_manager_1.ExtraDataTypeManager();
|
|
27
|
+
const namespaceArray = yield (0, node_opcua_pseudo_session_1.readNamespaceArray)(sessionPriv);
|
|
28
|
+
// istanbul ignore next
|
|
29
|
+
if (namespaceArray.length === 0) {
|
|
30
|
+
errorLog("namespaceArray is not populated ! Your server must expose a list of namespace ");
|
|
31
|
+
}
|
|
32
|
+
// istanbul ignore next
|
|
33
|
+
if (doDebug) {
|
|
34
|
+
debugLog("Namespace Array = ", namespaceArray.join("\n "));
|
|
35
|
+
}
|
|
36
|
+
sessionPriv.$$extraDataTypeManager = dataTypeManager;
|
|
37
|
+
dataTypeManager.setNamespaceArray(namespaceArray);
|
|
38
|
+
for (let namespaceIndex = 1; namespaceIndex < namespaceArray.length; namespaceIndex++) {
|
|
39
|
+
const dataTypeFactory1 = new node_opcua_factory_1.DataTypeFactory([(0, node_opcua_factory_1.getStandardDataTypeFactory)()]);
|
|
40
|
+
dataTypeManager.registerDataTypeFactory(namespaceIndex, dataTypeFactory1);
|
|
41
|
+
}
|
|
42
|
+
yield (0, populate_data_type_manager_1.populateDataTypeManager)(session, dataTypeManager);
|
|
43
|
+
}
|
|
44
|
+
// istanbul ignore next
|
|
45
|
+
if (sessionPriv.$$extraDataTypeManager.namespaceArray.length === 0) {
|
|
46
|
+
throw new Error("namespaceArray is not populated ! Your server must expose a list of namespace ");
|
|
47
|
+
}
|
|
48
|
+
return sessionPriv.$$extraDataTypeManager;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.getExtraDataTypeManager = getExtraDataTypeManager;
|
|
52
|
+
//# sourceMappingURL=get_extra_data_type_manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_extra_data_type_manager.js","sourceRoot":"","sources":["../source/get_extra_data_type_manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAgF;AAChF,2DAAiF;AACjF,yEAA8E;AAC9E,EAAE;AACF,uEAAiE;AACj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,CAAC,CAAC;SACrG;QACD,OAAO,WAAW,CAAC,sBAAsB,CAAC;IAC9C,CAAC;CAAA;AA3BD,0DA2BC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-client-dynamic-extension-object
|
|
3
|
+
*/
|
|
4
|
+
export * from "./populate_data_type_manager";
|
|
5
|
+
export * from "./extra_data_type_manager";
|
|
6
|
+
export * from "./resolve_dynamic_extension_object";
|
|
7
|
+
export * from "./promote_opaque_structure";
|
|
8
|
+
export * from "./get_extension_object_constructor";
|
|
9
|
+
export * from "./get_extra_data_type_manager";
|
|
10
|
+
export * from "./resolve_dynamic_extension_object";
|
|
11
|
+
export * from "./convert_data_type_definition_to_structuretype_schema";
|
|
12
|
+
export * from "./convert_structuretype_schema_to_structure_definition";
|
|
13
|
+
export * from "./promote_opaque_structure_in_notification_data";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* @module node-opcua-client-dynamic-extension-object
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("./populate_data_type_manager"), exports);
|
|
21
|
+
__exportStar(require("./extra_data_type_manager"), exports);
|
|
22
|
+
__exportStar(require("./resolve_dynamic_extension_object"), exports);
|
|
23
|
+
__exportStar(require("./promote_opaque_structure"), exports);
|
|
24
|
+
__exportStar(require("./get_extension_object_constructor"), exports);
|
|
25
|
+
__exportStar(require("./get_extra_data_type_manager"), exports);
|
|
26
|
+
__exportStar(require("./resolve_dynamic_extension_object"), exports);
|
|
27
|
+
__exportStar(require("./convert_data_type_definition_to_structuretype_schema"), exports);
|
|
28
|
+
__exportStar(require("./convert_structuretype_schema_to_structure_definition"), exports);
|
|
29
|
+
__exportStar(require("./promote_opaque_structure_in_notification_data"), exports);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,+DAA6C;AAC7C,4DAA0C;AAC1C,qEAAmD;AACnD,6DAA2C;AAC3C,qEAAmD;AACnD,gEAA8C;AAC9C,qEAAmD;AACnD,yFAAuE;AACvE,yFAAuE;AACvE,kFAAgE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.populateDataTypeManager = void 0;
|
|
13
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
14
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
15
|
+
const node_opcua_pseudo_session_1 = require("node-opcua-pseudo-session");
|
|
16
|
+
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
17
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
18
|
+
const populate_data_type_manager_103_1 = require("./private/populate_data_type_manager_103");
|
|
19
|
+
const populate_data_type_manager_104_1 = require("./private/populate_data_type_manager_104");
|
|
20
|
+
function serverImplementsDataTypeDefinition(session) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
// check if server provides DataTypeDefinition => in this case this is the prefered route,
|
|
23
|
+
// as we go along, more and more servers will implement this.
|
|
24
|
+
const browseResult = yield (0, node_opcua_pseudo_session_1.browseAll)(session, {
|
|
25
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
26
|
+
includeSubtypes: true,
|
|
27
|
+
nodeClassMask: node_opcua_data_model_1.NodeClassMask.DataType,
|
|
28
|
+
nodeId: (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_variant_1.DataType.ExtensionObject),
|
|
29
|
+
referenceTypeId: "HasSubtype",
|
|
30
|
+
resultMask: 63
|
|
31
|
+
});
|
|
32
|
+
const browseResult2 = yield (0, node_opcua_pseudo_session_1.browseAll)(session, {
|
|
33
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
34
|
+
includeSubtypes: true,
|
|
35
|
+
nodeClassMask: node_opcua_data_model_1.NodeClassMask.DataType,
|
|
36
|
+
nodeId: (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.DataTypeIds.Union),
|
|
37
|
+
referenceTypeId: "HasSubtype",
|
|
38
|
+
resultMask: 63
|
|
39
|
+
});
|
|
40
|
+
let references = [];
|
|
41
|
+
if (browseResult && browseResult.references)
|
|
42
|
+
references = references.concat(browseResult.references);
|
|
43
|
+
if (browseResult2 && browseResult2.references)
|
|
44
|
+
references = references.concat(browseResult2.references);
|
|
45
|
+
if (references.length === 0)
|
|
46
|
+
return false;
|
|
47
|
+
// DataType Structure from namespace 0 are not interesting and will not provide DataTypeDefinition attribute anyway
|
|
48
|
+
// on some servers.
|
|
49
|
+
references = references.filter((a, index) => a.nodeId.namespace !== 0);
|
|
50
|
+
if (references.length === 0)
|
|
51
|
+
return false;
|
|
52
|
+
let nodesToRead = references.map((r) => ({
|
|
53
|
+
nodeId: r.nodeId,
|
|
54
|
+
attributeId: node_opcua_data_model_1.AttributeIds.DataTypeDefinition
|
|
55
|
+
}));
|
|
56
|
+
const nodesToRead2 = nodesToRead.map((r) => ({ nodeId: r.nodeId, attributeId: node_opcua_data_model_1.AttributeIds.IsAbstract }));
|
|
57
|
+
const abstractFlags = (yield session.read(nodesToRead2)).map((d) => d.value.value);
|
|
58
|
+
// also remove the abstract dataStructure => they don't provide valid DataTypeDefinition
|
|
59
|
+
nodesToRead = nodesToRead.filter((_nodesToRead, index) => !abstractFlags[index]);
|
|
60
|
+
if (nodesToRead.length === 0)
|
|
61
|
+
return false;
|
|
62
|
+
const dataValues = yield session.read(nodesToRead);
|
|
63
|
+
// for (let i = 0; i < dataValues.length; i++) {
|
|
64
|
+
// console.log(i, " | ", nodesToRead[i].nodeId.toString().padEnd(40), references[i].browseName.toString().padEnd(50), dataValues[i].statusCode.toString());
|
|
65
|
+
// }
|
|
66
|
+
const countOK = dataValues.reduce((prev, a) => prev + (a.statusCode.isGood() ? 1 : 0), 0);
|
|
67
|
+
if (countOK === dataValues.length) {
|
|
68
|
+
return true;
|
|
69
|
+
// await populateDataTypeManager104(session, dataTypeManager);
|
|
70
|
+
// return;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function populateDataTypeManager(session, dataTypeManager) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const force104 = yield serverImplementsDataTypeDefinition(session);
|
|
78
|
+
if (force104) {
|
|
79
|
+
// console.log("xxxxxxx! using 1.04");
|
|
80
|
+
yield (0, populate_data_type_manager_104_1.populateDataTypeManager104)(session, dataTypeManager);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// old way for 1.03 and early 1.04 prototype
|
|
84
|
+
yield (0, populate_data_type_manager_103_1.populateDataTypeManager103)(session, dataTypeManager);
|
|
85
|
+
yield (0, populate_data_type_manager_104_1.populateDataTypeManager104)(session, dataTypeManager);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.populateDataTypeManager = populateDataTypeManager;
|
|
89
|
+
//# sourceMappingURL=populate_data_type_manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"populate_data_type_manager.js","sourceRoot":"","sources":["../source/populate_data_type_manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iEAAqF;AACrF,yDAAgE;AAChE,yEAAqE;AACrE,+DAAmD;AAGnD,2DAA8C;AAI9C,6FAAsF;AACtF,6FAAsF;AAEtF,SAAe,kCAAkC,CAAC,OAAsB;;QACpE,0FAA0F;QAC1F,6DAA6D;QAC7D,MAAM,YAAY,GAAG,MAAM,IAAA,qCAAS,EAAC,OAAO,EAAE;YAC1C,eAAe,EAAE,uCAAe,CAAC,OAAO;YACxC,eAAe,EAAE,IAAI;YACrB,aAAa,EAAE,qCAAa,CAAC,QAAQ;YACrC,MAAM,EAAE,IAAA,iCAAa,EAAC,6BAAQ,CAAC,eAAe,CAAC;YAC/C,eAAe,EAAE,YAAY;YAC7B,UAAU,EAAE,EAAE;SACjB,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,IAAA,qCAAS,EAAC,OAAO,EAAE;YAC3C,eAAe,EAAE,uCAAe,CAAC,OAAO;YACxC,eAAe,EAAE,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BasicSession } from "node-opcua-pseudo-session";
|
|
3
|
+
import { DataTypeAndEncodingId } from "node-opcua-schemas";
|
|
4
|
+
export declare function _findEncodings(session: IBasicSession, dataTypeNodeId: NodeId): Promise<DataTypeAndEncodingId>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports._findEncodings = void 0;
|
|
13
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
14
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
15
|
+
const node_opcua_pseudo_session_1 = require("node-opcua-pseudo-session");
|
|
16
|
+
function _findEncodings(session, dataTypeNodeId) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const nodeToBrowse = {
|
|
19
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
20
|
+
includeSubtypes: true,
|
|
21
|
+
nodeClassMask: (0, node_opcua_data_model_1.makeNodeClassMask)("Object"),
|
|
22
|
+
nodeId: dataTypeNodeId,
|
|
23
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasEncoding"),
|
|
24
|
+
resultMask: (0, node_opcua_data_model_1.makeResultMask)("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition")
|
|
25
|
+
};
|
|
26
|
+
const result = yield (0, node_opcua_pseudo_session_1.browseAll)(session, nodeToBrowse);
|
|
27
|
+
const references = result.references || [];
|
|
28
|
+
if (references.length === 0) {
|
|
29
|
+
// xx throw new Error("Cannot find encodings on type " + dataTypeNodeId.toString() + " statusCode " + result.statusCode.toString());
|
|
30
|
+
}
|
|
31
|
+
const encodings = {
|
|
32
|
+
dataTypeNodeId,
|
|
33
|
+
binaryEncodingNodeId: new node_opcua_nodeid_1.NodeId(),
|
|
34
|
+
jsonEncodingNodeId: new node_opcua_nodeid_1.NodeId(),
|
|
35
|
+
xmlEncodingNodeId: new node_opcua_nodeid_1.NodeId()
|
|
36
|
+
};
|
|
37
|
+
for (const ref of references) {
|
|
38
|
+
switch (ref.browseName.name) {
|
|
39
|
+
case "Default Binary":
|
|
40
|
+
encodings.binaryEncodingNodeId = ref.nodeId;
|
|
41
|
+
break;
|
|
42
|
+
case "Default XML":
|
|
43
|
+
encodings.xmlEncodingNodeId = ref.nodeId;
|
|
44
|
+
break;
|
|
45
|
+
case "Default JSON":
|
|
46
|
+
encodings.jsonEncodingNodeId = ref.nodeId;
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
console.log(" ignoring encoding ", ref.browseName.toString());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return encodings;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports._findEncodings = _findEncodings;
|
|
56
|
+
//# sourceMappingURL=find_encodings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find_encodings.js","sourceRoot":"","sources":["../../source/private/find_encodings.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA2F;AAC3F,yDAA0D;AAC1D,yEAA4F;AAG5F,SAAsB,cAAc,CAAC,OAAsB,EAAE,cAAsB;;QAC/E,MAAM,YAAY,GAA0B;YACxC,eAAe,EAAE,uCAAe,CAAC,OAAO;YACxC,eAAe,EAAE,IAAI;YACrB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
+
* Extract all custom dataType
|
|
5
|
+
* @param session
|
|
6
|
+
* @param dataTypeManager
|
|
7
|
+
* @async
|
|
8
|
+
*/
|
|
9
|
+
export declare function populateDataTypeManager103(session: IBasicSession, dataTypeManager: ExtraDataTypeManager): Promise<void>;
|