node-opcua-address-space 2.186.17 → 2.187.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/api/address_space_public.ts +16 -0
- package/api/helpers/resolve_opaque_on_address_space.ts +13 -1
- package/api/index.ts +14 -3
- package/api/loader/store_record_applier.ts +267 -0
- package/api/session_context.ts +116 -27
- package/dist/api/address_space_public.d.ts +14 -0
- package/dist/api/address_space_public.d.ts.map +1 -1
- package/dist/api/address_space_public.js +3 -0
- package/dist/api/address_space_public.js.map +1 -1
- package/dist/api/helpers/resolve_opaque_on_address_space.d.ts +6 -0
- package/dist/api/helpers/resolve_opaque_on_address_space.d.ts.map +1 -1
- package/dist/api/helpers/resolve_opaque_on_address_space.js +12 -1
- package/dist/api/helpers/resolve_opaque_on_address_space.js.map +1 -1
- package/dist/api/index.d.ts +4 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +4 -3
- package/dist/api/index.js.map +1 -1
- package/dist/api/loader/store_record_applier.d.ts +49 -0
- package/dist/api/loader/store_record_applier.d.ts.map +1 -0
- package/dist/api/loader/store_record_applier.js +235 -0
- package/dist/api/loader/store_record_applier.js.map +1 -0
- package/dist/api/session_context.d.ts +10 -0
- package/dist/api/session_context.d.ts.map +1 -1
- package/dist/api/session_context.js +100 -27
- package/dist/api/session_context.js.map +1 -1
- package/dist/impl/address_space.d.ts +2 -0
- package/dist/impl/address_space.d.ts.map +1 -1
- package/dist/impl/address_space.js +12 -2
- package/dist/impl/address_space.js.map +1 -1
- package/dist/impl/base_node_impl.d.ts +12 -0
- package/dist/impl/base_node_impl.d.ts.map +1 -1
- package/dist/impl/base_node_impl.js +35 -29
- package/dist/impl/base_node_impl.js.map +1 -1
- package/dist/impl/base_node_private.d.ts +5 -5
- package/dist/impl/base_node_private.d.ts.map +1 -1
- package/dist/impl/base_node_private.js +11 -5
- package/dist/impl/base_node_private.js.map +1 -1
- package/dist/impl/extension_object_array_node.d.ts +4 -2
- package/dist/impl/extension_object_array_node.d.ts.map +1 -1
- package/dist/impl/extension_object_array_node.js +5 -2
- package/dist/impl/extension_object_array_node.js.map +1 -1
- package/dist/impl/historical_access/address_space_historical_data_node.d.ts +26 -2
- package/dist/impl/historical_access/address_space_historical_data_node.d.ts.map +1 -1
- package/dist/impl/historical_access/address_space_historical_data_node.js +39 -0
- package/dist/impl/historical_access/address_space_historical_data_node.js.map +1 -1
- package/dist/impl/namespace_impl.d.ts.map +1 -1
- package/dist/impl/namespace_impl.js +3 -1
- package/dist/impl/namespace_impl.js.map +1 -1
- package/dist/impl/nodeid_manager.d.ts.map +1 -1
- package/dist/impl/nodeid_manager.js +10 -7
- package/dist/impl/nodeid_manager.js.map +1 -1
- package/dist/impl/nodeset_tools/construct_namespace_dependency.d.ts.map +1 -1
- package/dist/impl/nodeset_tools/construct_namespace_dependency.js +28 -0
- package/dist/impl/nodeset_tools/construct_namespace_dependency.js.map +1 -1
- package/dist/impl/reference_impl.d.ts +2 -1
- package/dist/impl/reference_impl.d.ts.map +1 -1
- package/dist/impl/reference_impl.js +6 -5
- package/dist/impl/reference_impl.js.map +1 -1
- package/dist/impl/reference_index.d.ts +22 -0
- package/dist/impl/reference_index.d.ts.map +1 -0
- package/dist/impl/reference_index.js +104 -0
- package/dist/impl/reference_index.js.map +1 -0
- package/dist/impl/ua_variable_impl.d.ts +10 -0
- package/dist/impl/ua_variable_impl.d.ts.map +1 -1
- package/dist/impl/ua_variable_impl.js +152 -106
- package/dist/impl/ua_variable_impl.js.map +1 -1
- package/dist/tsconfig_base.tsbuildinfo +1 -1
- package/distNodeJS/generate_address_space.d.ts +6 -1
- package/distNodeJS/generate_address_space.d.ts.map +1 -1
- package/distNodeJS/generate_address_space.js +33 -1
- package/distNodeJS/generate_address_space.js.map +1 -1
- package/impl/address_space.ts +16 -2
- package/impl/base_node_impl.ts +52 -30
- package/impl/base_node_private.ts +16 -10
- package/impl/extension_object_array_node.ts +12 -3
- package/impl/historical_access/address_space_historical_data_node.ts +64 -1
- package/impl/namespace_impl.ts +3 -1
- package/impl/nodeid_manager.ts +10 -7
- package/impl/nodeset_tools/construct_namespace_dependency.ts +23 -1
- package/impl/reference_impl.ts +6 -5
- package/impl/reference_index.ts +116 -0
- package/impl/ua_variable_impl.ts +203 -115
- package/package.json +34 -33
- package/source_nodejs/generate_address_space.ts +46 -1
|
@@ -3,7 +3,8 @@ import assert from "node-opcua-assert";
|
|
|
3
3
|
import { DataType } from "node-opcua-basic-types";
|
|
4
4
|
import { NodeClass } from "node-opcua-data-model";
|
|
5
5
|
import { make_debugLog, make_warningLog } from "node-opcua-debug";
|
|
6
|
-
import
|
|
6
|
+
import { ExtensionObject } from "node-opcua-extension-object";
|
|
7
|
+
import { NodeId } from "node-opcua-nodeid";
|
|
7
8
|
import type { StructureField } from "node-opcua-types";
|
|
8
9
|
import { Variant } from "node-opcua-variant";
|
|
9
10
|
import type { TranslationTable } from "../../api/xml_writer.js";
|
|
@@ -11,6 +12,7 @@ import type { BaseNodeImpl } from "../base_node_impl.js";
|
|
|
11
12
|
import type { NamespacePrivate } from "../namespace_private.js";
|
|
12
13
|
import { ReferenceImpl } from "../reference_impl.js";
|
|
13
14
|
import type { UAVariableImpl } from "../ua_variable_impl.js";
|
|
15
|
+
import type { UAVariableTypeImpl } from "../ua_variable_type_impl.js";
|
|
14
16
|
|
|
15
17
|
const warningLog = make_warningLog("construct_namespace_dependency");
|
|
16
18
|
const _debugLog = make_debugLog("construct_namespace_dependency");
|
|
@@ -212,11 +214,31 @@ export function _getCompleteRequiredModelsFromValuesAndReferences(
|
|
|
212
214
|
}
|
|
213
215
|
};
|
|
214
216
|
|
|
217
|
+
// the exporter translates every NodeId a value holds (an Argument's DataType, a NodeId field of
|
|
218
|
+
// a structure, a NodeId variable), so each of their namespaces is a dependency whatever its priority
|
|
219
|
+
const exploreValue = (value: unknown): void => {
|
|
220
|
+
if (value === null || value === undefined) return;
|
|
221
|
+
if (value instanceof NodeId) {
|
|
222
|
+
consider(value.namespace);
|
|
223
|
+
} else if (value instanceof Variant) {
|
|
224
|
+
exploreValue(value.value);
|
|
225
|
+
} else if (Array.isArray(value)) {
|
|
226
|
+
for (const element of value) exploreValue(element);
|
|
227
|
+
} else if (value instanceof ExtensionObject) {
|
|
228
|
+
for (const fieldValue of Object.values(value)) exploreValue(fieldValue);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
215
232
|
const addressSpace = namespace.addressSpace;
|
|
216
233
|
const nonHierarchicalReferencesType = addressSpace.findReferenceType("NonHierarchicalReferences");
|
|
217
234
|
|
|
218
235
|
//const maxIndex = Math.max(...requiredNamespaceIndexes);
|
|
219
236
|
for (const node of namespace_.nodeIterator()) {
|
|
237
|
+
if (node.nodeClass === NodeClass.Variable) {
|
|
238
|
+
exploreValue((node as UAVariableImpl).$dataValue?.value);
|
|
239
|
+
} else if (node.nodeClass === NodeClass.VariableType) {
|
|
240
|
+
exploreValue((node as UAVariableTypeImpl).value);
|
|
241
|
+
}
|
|
220
242
|
const references = (<BaseNodeImpl>node).allReferences();
|
|
221
243
|
for (const reference of references) {
|
|
222
244
|
// check referenceId
|
package/impl/reference_impl.ts
CHANGED
|
@@ -157,7 +157,8 @@ export class ReferenceImpl implements UAReference {
|
|
|
157
157
|
|
|
158
158
|
// cache
|
|
159
159
|
private __hash?: string;
|
|
160
|
-
|
|
160
|
+
/** the key this reference is indexed under, computed once by key(); read by ReferenceIndex */
|
|
161
|
+
public _key?: ReferenceKey;
|
|
161
162
|
|
|
162
163
|
constructor(options: AddReferenceOpts | UAReference) {
|
|
163
164
|
assert(options.referenceType instanceof NodeId);
|
|
@@ -209,10 +210,10 @@ export class ReferenceImpl implements UAReference {
|
|
|
209
210
|
* the key this reference is indexed under in the node holding it, computed once
|
|
210
211
|
*/
|
|
211
212
|
key(ordinals: ReferenceTypeOrdinals): ReferenceKey {
|
|
212
|
-
if (this.
|
|
213
|
-
this.
|
|
213
|
+
if (this._key === undefined) {
|
|
214
|
+
this._key = referenceKey(this.isForward, ordinals.referenceTypeOrdinal(this.referenceType), nodeIdKey(this.nodeId));
|
|
214
215
|
}
|
|
215
|
-
return this.
|
|
216
|
+
return this._key;
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
/**
|
|
@@ -230,7 +231,7 @@ export class ReferenceImpl implements UAReference {
|
|
|
230
231
|
*/
|
|
231
232
|
public dispose(): void {
|
|
232
233
|
this.__hash = undefined;
|
|
233
|
-
this
|
|
234
|
+
// _key stays: the index holding this reference finds it by that key (ReferenceIndex)
|
|
234
235
|
this.node = undefined;
|
|
235
236
|
/*
|
|
236
237
|
this._referenceType = null;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { UAReference } from "node-opcua-address-space-base";
|
|
2
|
+
import type { ReferenceImpl, ReferenceKey } from "./reference_impl.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* above this many references a node indexes them in a Map; below, a plain array scanned on
|
|
6
|
+
* lookup. A leaf node holds two or three references, and a Map with its hash table costs
|
|
7
|
+
* about 280 bytes even when nearly empty: a quarter of what a node weighs. On a model of a
|
|
8
|
+
* million nodes that is the difference between fitting in memory and not.
|
|
9
|
+
*/
|
|
10
|
+
const MAP_THRESHOLD = 16;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The references a node holds, by key (see ReferenceImpl#key). It offers what the code uses of
|
|
14
|
+
* a Map: get, has, set, delete, values, size and iteration.
|
|
15
|
+
*
|
|
16
|
+
* The key is not stored twice: a reference caches its own key when it is indexed, and a scan
|
|
17
|
+
* compares that cached key.
|
|
18
|
+
*/
|
|
19
|
+
export class ReferenceIndex {
|
|
20
|
+
#refs: UAReference[] | null = null;
|
|
21
|
+
#map: Map<ReferenceKey, UAReference> | null = null;
|
|
22
|
+
|
|
23
|
+
public get size(): number {
|
|
24
|
+
return this.#map ? this.#map.size : this.#refs ? this.#refs.length : 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#indexOf(key: ReferenceKey): number {
|
|
28
|
+
const refs = this.#refs as ReferenceImpl[];
|
|
29
|
+
for (let i = 0; i < refs.length; i++) {
|
|
30
|
+
if (refs[i]._key === key) {
|
|
31
|
+
return i;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return -1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public has(key: ReferenceKey): boolean {
|
|
38
|
+
if (this.#map) {
|
|
39
|
+
return this.#map.has(key);
|
|
40
|
+
}
|
|
41
|
+
return this.#refs !== null && this.#indexOf(key) !== -1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public get(key: ReferenceKey): UAReference | undefined {
|
|
45
|
+
if (this.#map) {
|
|
46
|
+
return this.#map.get(key);
|
|
47
|
+
}
|
|
48
|
+
if (this.#refs === null) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const index = this.#indexOf(key);
|
|
52
|
+
return index === -1 ? undefined : this.#refs[index];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** `key` must be the reference's own key (ReferenceImpl#key), which is what callers index by */
|
|
56
|
+
public set(key: ReferenceKey, reference: UAReference): this {
|
|
57
|
+
if (this.#map) {
|
|
58
|
+
this.#map.set(key, reference);
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
if (this.#refs === null) {
|
|
62
|
+
this.#refs = [reference];
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
const index = this.#indexOf(key);
|
|
66
|
+
if (index !== -1) {
|
|
67
|
+
this.#refs[index] = reference; // check-proto-pollution: ok - numeric index
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
if (this.#refs.length >= MAP_THRESHOLD) {
|
|
71
|
+
const map = new Map<ReferenceKey, UAReference>();
|
|
72
|
+
for (const ref of this.#refs) {
|
|
73
|
+
map.set((ref as ReferenceImpl)._key as ReferenceKey, ref);
|
|
74
|
+
}
|
|
75
|
+
map.set(key, reference);
|
|
76
|
+
this.#map = map;
|
|
77
|
+
this.#refs = null;
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
// concat allocates exactly the length needed; push would grow the backing store to 17
|
|
81
|
+
// slots, which is more than the Map this replaces
|
|
82
|
+
this.#refs = this.#refs.concat(reference);
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public delete(key: ReferenceKey): boolean {
|
|
87
|
+
if (this.#map) {
|
|
88
|
+
return this.#map.delete(key);
|
|
89
|
+
}
|
|
90
|
+
if (this.#refs === null) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const index = this.#indexOf(key);
|
|
94
|
+
if (index === -1) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
this.#refs = this.#refs.length === 1 ? null : this.#refs.filter((_r, i) => i !== index);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public clear(): void {
|
|
102
|
+
this.#refs = null;
|
|
103
|
+
this.#map = null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public values(): IterableIterator<UAReference> {
|
|
107
|
+
if (this.#map) {
|
|
108
|
+
return this.#map.values();
|
|
109
|
+
}
|
|
110
|
+
return (this.#refs ?? []).values();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public [Symbol.iterator](): IterableIterator<UAReference> {
|
|
114
|
+
return this.values();
|
|
115
|
+
}
|
|
116
|
+
}
|