import type { BaseNode, CloneExtraInfo, CloneFilter, IAddressSpace, ISessionContext, UAMethod, UAObject, UAObjectType, UAReference, UAReferenceType, UAVariable, UAVariableT, UAVariableType } from "node-opcua-address-space-base"; import { type CloneOptions } from "node-opcua-address-space-base"; import type { DataType } from "node-opcua-basic-types"; import { type LocalizedText, type LocalizedTextLike } from "node-opcua-data-model"; import { NodeId } from "node-opcua-nodeid"; import { ReferenceDescription } from "node-opcua-types"; import { BaseNodeImpl } from "./base_node_impl.js"; import { type ReferenceKey } from "./reference_impl.js"; interface BaseNodeCacheInner { typeDefinition?: NodeId; typeDefinitionObj?: UAVariableType | UAObjectType | null; _children?: BaseNode[]; _versionNode?: UAVariableT | null; _ref?: Map; /** * memoized `findReferencesEx`: per reference type node, the forward then the inverse result; * dropped with the rest of the cache on every reference added or removed, and when the * reference-type hierarchy moved (`_refExVersion`) */ _refEx?: Map; _refExVersion?: number; _encoding?: Map; _subtype_idx?: Map | null; _subtype_idxVersion?: number; _allSubTypes?: UAReferenceType[] | null; _allSubTypesVersion?: number; _subtypeOfObj?: BaseNode | null; } export type UAReferenceWithNodeRef = UAReference & { node: BaseNode; }; export type HierarchicalIndexMap = Map; /** * the memoized scans of one node for one reference type: forward, inverse, and for each whether * a reference in it still waits for its target (the target may be created after the scan; the * memo then resolves it on the next hit rather than hand out a reference without a node) */ export type ReferenceScanMemo = [UAReference[] | undefined, UAReference[] | undefined, boolean, boolean]; interface BaseNodeCache { _childByNameMap?: HierarchicalIndexMap; /** * set when a reference could not be indexed (target node or reference type not in the * address space yet): the index is rebuilt on the next lookup instead of missing a child */ _childByNameMapIncomplete?: boolean; /** * the reference-type hierarchy the index was built against (referenceTypeVersion.count): a * reference of a type that became hierarchical since is not in it, so it is rebuilt */ _childByNameMapVersion?: number; __address_space: IAddressSpace | null; _browseFilter?: (this: BaseNode, context?: ISessionContext) => boolean; /** created on first use: a node that is never looked at pays nothing here */ _cache?: BaseNodeCacheInner; /** built from _descriptionRaw on first read */ _description?: LocalizedText; _descriptionRaw?: LocalizedTextLike | null; /** built from _displayNameRaw on first read */ _displayName?: LocalizedText[]; _displayNameRaw?: LocalizedTextLike | LocalizedTextLike[]; _parent?: BaseNode | null; /** * the references other nodes hold to this one; `EMPTY_REFERENCE_INDEX` until the first one * arrives, since a nodeset declares most references from both ends and most nodes never get one */ _back_referenceIdx: Map; _referenceIdx: Map; /** the property name this node is exposed as on its parents (see child_accessors.ts) */ _accessorName?: string; } export declare function BaseNode_initPrivate(self: BaseNode): BaseNodeCache; export declare function BaseNode_removePrivate(self: BaseNode): void; /** * Drop the child index; it is rebuilt lazily on the next lookup. The nodeset loader calls this on * every node once a load is complete, so an index built before the load (a second nodeset added at * runtime to an address space already in use) cannot go stale. */ export declare function BaseNode_resetChildIndex(node: BaseNode): void; export declare function BaseNode_getPrivate(self: BaseNode): BaseNodeCache; export declare function BaseNode_getCache(node: BaseNode): BaseNodeCacheInner; export declare function BaseNode_clearCache(node: BaseNode): void; export interface ToStringOptionBase { level: number; cycleDetector: Record; padding: string; } export interface ToStringOption extends ToStringOptionBase { add(someLine: string): void; indent(a: string, b: string | null): void; } export declare class ToStringBuilder implements ToStringOption { level: number; cycleDetector: Record; padding: string; private str; constructor(); add(line: string): void; toString(): string; indent(str: string, padding: string | null): string; } export declare function BaseNode_toString(this: BaseNode, options: ToStringOption): void; export declare function BaseNode_References_toString(this: BaseNode, options: ToStringOption): void; export declare function UAVariableType_toString(this: UAVariableType, options: ToStringOption): void; export declare function UAVariable_toString(this: UAVariable, options: ToStringOption): void; export declare function UAObject_toString(this: UAObject, options: ToStringOption): void; export declare function UAObjectType_toString(this: UAObjectType, options: ToStringOption): void; export declare function valueRankToString(valueRank: number): string; export declare function VariableOrVariableType_toString(this: UAVariableType | UAVariable, options: ToStringOption): void; export declare function _clone_hierarchical_references(nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType, newParent: UAObject | UAVariable | UAMethod, copyAlsoModellingRules: boolean, optionalFilter: CloneFilter, extraInfo: CloneExtraInfo, browseNameMap: Set): void; export declare function _clone_non_hierarchical_references(nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType, newParent: BaseNode, copyAlsoModellingRules: boolean, optionalFilter: CloneFilter, extraInfo: CloneExtraInfo, browseNameMap: Set): void; /** * @private */ export declare function _clone(originalNode: T, Constructor: new (options: O) => T, options: CloneOptions, optionalFilter: CloneFilter, extraInfo: CloneExtraInfo): T; /** * keep an existing child index in step with a forward reference just added to `node` */ export declare function _handle_HierarchicalReference(node: BaseNode, reference: UAReference): void; /** * The child index of `node`: browse name -> forward hierarchical reference(s), target resolved. * * Built lazily and kept by `_handle_HierarchicalReference` / `_remove_HierarchicalReference`. It is * not kept while a nodeset is loading (`suspendBackReference`) nor when some target could not be * resolved: a lookup then gets a transient map and the next one rebuilds. Before namespace 0 has * loaded `HierarchicalReferences` nothing can be hierarchical yet and the map is empty. */ export declare function _get_HierarchicalReference(node: BaseNode): HierarchicalIndexMap; export declare function _remove_HierarchicalReference(node: BaseNodeImpl, reference: UAReference): void; export declare function _constructReferenceDescription(addressSpace: IAddressSpace, references: UAReference[], resultMask: number): ReferenceDescription[]; export declare function BaseNode_remove_backward_reference(this: BaseNodeImpl, reference: UAReference): void; /** * a reference added to or removed from a reference type may move it in the hierarchy (a * HasSubtype link made at runtime): every memo built against the hierarchy is then stale */ export declare function noteReferenceTypeChange(node: BaseNode, reference?: UAReference): void; export declare function BaseNode_add_backward_reference(this: BaseNodeImpl, reference: UAReference): void; export {};