node-opcua-client-dynamic-extension-object 2.71.0 → 2.72.2

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 (29) hide show
  1. package/dist/convert_data_type_definition_to_structuretype_schema.d.ts +12 -12
  2. package/dist/convert_data_type_definition_to_structuretype_schema.js +343 -343
  3. package/dist/extra_data_type_manager.d.ts +16 -16
  4. package/dist/extra_data_type_manager.js +75 -75
  5. package/dist/get_extension_object_constructor.d.ts +7 -7
  6. package/dist/get_extension_object_constructor.js +37 -37
  7. package/dist/get_extra_data_type_manager.d.ts +3 -3
  8. package/dist/get_extra_data_type_manager.js +51 -51
  9. package/dist/index.d.ts +12 -12
  10. package/dist/index.js +28 -28
  11. package/dist/populate_data_type_manager.d.ts +3 -3
  12. package/dist/populate_data_type_manager.js +25 -25
  13. package/dist/private/find_encodings.d.ts +4 -4
  14. package/dist/private/find_encodings.js +55 -55
  15. package/dist/private/populate_data_type_manager_103.d.ts +9 -9
  16. package/dist/private/populate_data_type_manager_103.js +601 -601
  17. package/dist/private/populate_data_type_manager_104.d.ts +9 -9
  18. package/dist/private/populate_data_type_manager_104.js +182 -182
  19. package/dist/promote_opaque_structure.d.ts +6 -6
  20. package/dist/promote_opaque_structure.js +41 -41
  21. package/dist/promote_opaque_structure_in_notification_data.d.ts +3 -3
  22. package/dist/promote_opaque_structure_in_notification_data.js +51 -51
  23. package/dist/resolve_dynamic_extension_object.d.ts +4 -4
  24. package/dist/resolve_dynamic_extension_object.js +105 -105
  25. package/package.json +12 -12
  26. package/LICENSE +0 -20
  27. package/dist/client_dynamic_extension_object.d.ts +0 -22
  28. package/dist/client_dynamic_extension_object.js +0 -1012
  29. package/dist/client_dynamic_extension_object.js.map +0 -1
@@ -1,106 +1,106 @@
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.resolveDynamicExtensionObject = void 0;
13
- const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
14
- const node_opcua_extension_object_1 = require("node-opcua-extension-object");
15
- const node_opcua_variant_1 = require("node-opcua-variant");
16
- const node_opcua_debug_1 = require("node-opcua-debug");
17
- const node_opcua_data_model_1 = require("node-opcua-data-model");
18
- const node_opcua_status_code_1 = require("node-opcua-status-code");
19
- const populate_data_type_manager_104_1 = require("./private/populate_data_type_manager_104");
20
- const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
21
- function getOrExtractConstructor(session, binaryEncodingNodeId, dataTypeManager) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(binaryEncodingNodeId.namespace);
24
- const Constructor = dataTypeFactory.getConstructor(binaryEncodingNodeId);
25
- if (Constructor) {
26
- return Constructor;
27
- }
28
- if (binaryEncodingNodeId.namespace === 0) {
29
- throw new Error("Internal Error");
30
- }
31
- // need to extract it
32
- const browseResult = yield session.browse({
33
- nodeId: binaryEncodingNodeId,
34
- referenceTypeId: "HasEncoding",
35
- browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
36
- includeSubtypes: false,
37
- nodeClassMask: node_opcua_data_model_1.NodeClassMask.DataType,
38
- resultMask: node_opcua_data_model_1.ResultMask.BrowseName
39
- });
40
- if (browseResult.statusCode !== node_opcua_status_code_1.StatusCodes.Good || browseResult.references.length !== 1) {
41
- throw new Error("browse failed");
42
- }
43
- const r = browseResult.references[0];
44
- const dataTypeNodeId = r.nodeId;
45
- if (dataTypeFactory.getConstructorForDataType(dataTypeNodeId)) {
46
- throw new Error("Internal Error: we are not expecting this dataType to be processed already");
47
- }
48
- yield (0, populate_data_type_manager_104_1.readDataTypeDefinitionAndBuildType)(session, dataTypeNodeId, r.browseName.name, dataTypeFactory, {});
49
- return dataTypeFactory.getConstructorForDataType(dataTypeNodeId);
50
- });
51
- }
52
- function resolveDynamicExtensionObjectV(session, opaque, dataTypeManager) {
53
- var _a, _b;
54
- return __awaiter(this, void 0, void 0, function* () {
55
- try {
56
- const Constructor = yield getOrExtractConstructor(session, opaque.nodeId, dataTypeManager);
57
- const object = new Constructor();
58
- const stream = new node_opcua_binary_stream_1.BinaryStream(opaque.buffer);
59
- try {
60
- object.decode(stream);
61
- return object;
62
- }
63
- catch (err) {
64
- warningLog("Constructor = ", Constructor.name);
65
- warningLog("opaqueStructure = ", (_a = opaque === null || opaque === void 0 ? void 0 : opaque.nodeId) === null || _a === void 0 ? void 0 : _a.toString());
66
- warningLog("opaqueStructure = ", "0x" + ((_b = opaque === null || opaque === void 0 ? void 0 : opaque.buffer) === null || _b === void 0 ? void 0 : _b.toString("hex")));
67
- warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
68
- warningLog("resolveDynamicExtensionObjectV err = ", err);
69
- // try again for debugging
70
- object.decode(stream);
71
- return opaque;
72
- }
73
- }
74
- catch (err) {
75
- warningLog("err", err);
76
- warningLog("opaqueStructure = ", opaque.nodeId.toString());
77
- warningLog("opaqueStructure = ", "0x" + opaque.buffer.toString("hex"));
78
- warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
79
- warningLog(dataTypeManager.toString());
80
- throw err;
81
- }
82
- });
83
- }
84
- function resolveDynamicExtensionObject(session, variant, dataTypeManager) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- if (variant.dataType !== node_opcua_variant_1.DataType.ExtensionObject) {
87
- return;
88
- }
89
- if (variant.arrayType !== node_opcua_variant_1.VariantArrayType.Scalar) {
90
- if (variant.value instanceof Array) {
91
- for (let i = 0; i < variant.value.length; i++) {
92
- if (variant.value[i] instanceof node_opcua_extension_object_1.OpaqueStructure) {
93
- variant.value[i] = yield resolveDynamicExtensionObjectV(session, variant.value[i], dataTypeManager);
94
- }
95
- }
96
- }
97
- return;
98
- }
99
- if (!(variant.value instanceof node_opcua_extension_object_1.OpaqueStructure)) {
100
- return;
101
- }
102
- variant.value = yield resolveDynamicExtensionObjectV(session, variant.value, dataTypeManager);
103
- });
104
- }
105
- exports.resolveDynamicExtensionObject = resolveDynamicExtensionObject;
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.resolveDynamicExtensionObject = void 0;
13
+ const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
14
+ const node_opcua_extension_object_1 = require("node-opcua-extension-object");
15
+ const node_opcua_variant_1 = require("node-opcua-variant");
16
+ const node_opcua_debug_1 = require("node-opcua-debug");
17
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
18
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
19
+ const populate_data_type_manager_104_1 = require("./private/populate_data_type_manager_104");
20
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
21
+ function getOrExtractConstructor(session, binaryEncodingNodeId, dataTypeManager) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(binaryEncodingNodeId.namespace);
24
+ const Constructor = dataTypeFactory.getConstructor(binaryEncodingNodeId);
25
+ if (Constructor) {
26
+ return Constructor;
27
+ }
28
+ if (binaryEncodingNodeId.namespace === 0) {
29
+ throw new Error("Internal Error");
30
+ }
31
+ // need to extract it
32
+ const browseResult = yield session.browse({
33
+ nodeId: binaryEncodingNodeId,
34
+ referenceTypeId: "HasEncoding",
35
+ browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
36
+ includeSubtypes: false,
37
+ nodeClassMask: node_opcua_data_model_1.NodeClassMask.DataType,
38
+ resultMask: node_opcua_data_model_1.ResultMask.BrowseName
39
+ });
40
+ if (browseResult.statusCode !== node_opcua_status_code_1.StatusCodes.Good || browseResult.references.length !== 1) {
41
+ throw new Error("browse failed");
42
+ }
43
+ const r = browseResult.references[0];
44
+ const dataTypeNodeId = r.nodeId;
45
+ if (dataTypeFactory.getConstructorForDataType(dataTypeNodeId)) {
46
+ throw new Error("Internal Error: we are not expecting this dataType to be processed already");
47
+ }
48
+ yield (0, populate_data_type_manager_104_1.readDataTypeDefinitionAndBuildType)(session, dataTypeNodeId, r.browseName.name, dataTypeFactory, {});
49
+ return dataTypeFactory.getConstructorForDataType(dataTypeNodeId);
50
+ });
51
+ }
52
+ function resolveDynamicExtensionObjectV(session, opaque, dataTypeManager) {
53
+ var _a, _b;
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ try {
56
+ const Constructor = yield getOrExtractConstructor(session, opaque.nodeId, dataTypeManager);
57
+ const object = new Constructor();
58
+ const stream = new node_opcua_binary_stream_1.BinaryStream(opaque.buffer);
59
+ try {
60
+ object.decode(stream);
61
+ return object;
62
+ }
63
+ catch (err) {
64
+ warningLog("Constructor = ", Constructor.name);
65
+ warningLog("opaqueStructure = ", (_a = opaque === null || opaque === void 0 ? void 0 : opaque.nodeId) === null || _a === void 0 ? void 0 : _a.toString());
66
+ warningLog("opaqueStructure = ", "0x" + ((_b = opaque === null || opaque === void 0 ? void 0 : opaque.buffer) === null || _b === void 0 ? void 0 : _b.toString("hex")));
67
+ warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
68
+ warningLog("resolveDynamicExtensionObjectV err = ", err);
69
+ // try again for debugging
70
+ object.decode(stream);
71
+ return opaque;
72
+ }
73
+ }
74
+ catch (err) {
75
+ warningLog("err", err);
76
+ warningLog("opaqueStructure = ", opaque.nodeId.toString());
77
+ warningLog("opaqueStructure = ", "0x" + opaque.buffer.toString("hex"));
78
+ warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
79
+ warningLog(dataTypeManager.toString());
80
+ throw err;
81
+ }
82
+ });
83
+ }
84
+ function resolveDynamicExtensionObject(session, variant, dataTypeManager) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ if (variant.dataType !== node_opcua_variant_1.DataType.ExtensionObject) {
87
+ return;
88
+ }
89
+ if (variant.arrayType !== node_opcua_variant_1.VariantArrayType.Scalar) {
90
+ if (variant.value instanceof Array) {
91
+ for (let i = 0; i < variant.value.length; i++) {
92
+ if (variant.value[i] instanceof node_opcua_extension_object_1.OpaqueStructure) {
93
+ variant.value[i] = yield resolveDynamicExtensionObjectV(session, variant.value[i], dataTypeManager);
94
+ }
95
+ }
96
+ }
97
+ return;
98
+ }
99
+ if (!(variant.value instanceof node_opcua_extension_object_1.OpaqueStructure)) {
100
+ return;
101
+ }
102
+ variant.value = yield resolveDynamicExtensionObjectV(session, variant.value, dataTypeManager);
103
+ });
104
+ }
105
+ exports.resolveDynamicExtensionObject = resolveDynamicExtensionObject;
106
106
  //# sourceMappingURL=resolve_dynamic_extension_object.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-client-dynamic-extension-object",
3
- "version": "2.71.0",
3
+ "version": "2.72.2",
4
4
  "description": "pure nodejs OPCUA SDK - module client-dynamic-extension-object",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -14,19 +14,19 @@
14
14
  "node-opcua-assert": "2.66.0",
15
15
  "node-opcua-binary-stream": "2.71.0",
16
16
  "node-opcua-constants": "2.70.0",
17
- "node-opcua-data-model": "2.71.0",
18
- "node-opcua-data-value": "2.71.0",
17
+ "node-opcua-data-model": "2.72.1",
18
+ "node-opcua-data-value": "2.72.2",
19
19
  "node-opcua-debug": "2.71.0",
20
- "node-opcua-extension-object": "2.71.0",
21
- "node-opcua-factory": "2.71.0",
20
+ "node-opcua-extension-object": "2.72.1",
21
+ "node-opcua-factory": "2.72.1",
22
22
  "node-opcua-nodeid": "2.71.0",
23
- "node-opcua-pseudo-session": "2.71.0",
24
- "node-opcua-schemas": "2.71.0",
25
- "node-opcua-service-browse": "2.71.0",
26
- "node-opcua-service-translate-browse-path": "2.71.0",
23
+ "node-opcua-pseudo-session": "2.72.2",
24
+ "node-opcua-schemas": "2.72.2",
25
+ "node-opcua-service-browse": "2.72.2",
26
+ "node-opcua-service-translate-browse-path": "2.72.2",
27
27
  "node-opcua-status-code": "2.71.0",
28
- "node-opcua-types": "2.71.0",
29
- "node-opcua-variant": "2.71.0"
28
+ "node-opcua-types": "2.72.2",
29
+ "node-opcua-variant": "2.72.2"
30
30
  },
31
31
  "author": "Etienne Rossignon",
32
32
  "license": "MIT",
@@ -43,5 +43,5 @@
43
43
  "internet of things"
44
44
  ],
45
45
  "homepage": "http://node-opcua.github.io/",
46
- "gitHead": "10f7cc1e1cd30dfef75adad9cb709a78401fabf3"
46
+ "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c"
47
47
  }
package/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014-2021 Etienne Rossignon
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,22 +0,0 @@
1
- import { DataTypeFactory, FieldCategory, StructuredTypeSchema, TypeDefinition } from "node-opcua-factory";
2
- import { NodeId } from "node-opcua-nodeid";
3
- import { IBasicSession } from "node-opcua-pseudo-session";
4
- import { DataTypeDefinition } from "node-opcua-types";
5
- import { ExtraDataTypeManager } from "./extra_data_type_manager";
6
- /**
7
- * Extract all custom dataType
8
- * @param session
9
- * @param dataTypeManager
10
- * @async
11
- */
12
- export declare function populateDataTypeManager(session: IBasicSession, dataTypeManager: ExtraDataTypeManager): Promise<void>;
13
- export declare function getDataTypeDefinition(session: IBasicSession, dataTypeNodeId: NodeId, dataTypeManager: ExtraDataTypeManager): Promise<StructuredTypeSchema>;
14
- interface Cache {
15
- fieldTypeName: string;
16
- schema: TypeDefinition;
17
- category: FieldCategory;
18
- }
19
- export declare function convertDataTypeDefinitionToStructureTypeSchema(session: IBasicSession, dataTypeNodeId: NodeId, name: string, definition: DataTypeDefinition, dataTypeFactory: DataTypeFactory, cache: {
20
- [key: string]: Cache;
21
- }): Promise<StructuredTypeSchema>;
22
- export {};