node-opcua-factory 2.71.0 → 2.73.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/base_ua_object.d.ts +53 -0
- package/dist/base_ua_object.js +536 -0
- package/dist/base_ua_object.js.map +1 -0
- package/dist/basic_type.d.ts +40 -0
- package/dist/basic_type.js +119 -0
- package/dist/basic_type.js.map +1 -0
- package/dist/builtin_types.d.ts +46 -0
- package/dist/builtin_types.js +284 -0
- package/dist/builtin_types.js.map +1 -0
- package/dist/builtin_types_special.d.ts +5 -0
- package/dist/builtin_types_special.js +46 -0
- package/dist/builtin_types_special.js.map +1 -0
- package/dist/constructor_type.d.ts +15 -15
- package/dist/constructor_type.js +2 -2
- package/dist/datatype_factory.d.ts +36 -39
- package/dist/datatype_factory.js +305 -322
- package/dist/datatype_factory.js.map +1 -1
- package/dist/encode_decode.d.ts +9 -0
- package/dist/encode_decode.js +40 -0
- package/dist/encode_decode.js.map +1 -0
- package/dist/enumerations.d.ts +32 -0
- package/dist/enumerations.js +78 -0
- package/dist/enumerations.js.map +1 -0
- package/dist/factories_baseobject.d.ts +56 -56
- package/dist/factories_baseobject.js +534 -534
- package/dist/factories_basic_type.d.ts +40 -40
- package/dist/factories_basic_type.js +135 -135
- package/dist/factories_builtin_types.d.ts +32 -32
- package/dist/factories_builtin_types.js +261 -261
- package/dist/factories_builtin_types_special.d.ts +5 -5
- package/dist/factories_builtin_types_special.js +45 -45
- package/dist/factories_enumerations.d.ts +31 -31
- package/dist/factories_enumerations.js +77 -77
- package/dist/factories_factories.d.ts +17 -17
- package/dist/factories_factories.js +53 -53
- package/dist/factories_id_generator.d.ts +3 -3
- package/dist/factories_id_generator.js +21 -21
- package/dist/factories_schema_helpers.d.ts +27 -27
- package/dist/factories_schema_helpers.js +121 -121
- package/dist/factories_structuredTypeSchema.d.ts +45 -45
- package/dist/factories_structuredTypeSchema.js +276 -276
- package/dist/get_built_in_type.d.ts +0 -0
- package/dist/get_built_in_type.js +2 -0
- package/dist/get_built_in_type.js.map +1 -0
- package/dist/get_standard_data_type_factory.d.ts +12 -0
- package/dist/get_standard_data_type_factory.js +35 -0
- package/dist/get_standard_data_type_factory.js.map +1 -0
- package/dist/get_structured_type_schema.d.ts +4 -0
- package/dist/get_structured_type_schema.js +13 -0
- package/dist/get_structured_type_schema.js.map +1 -0
- package/dist/id_generator.d.ts +3 -0
- package/dist/id_generator.js +22 -0
- package/dist/id_generator.js.map +1 -0
- package/dist/index.d.ts +18 -15
- package/dist/index.js +34 -31
- package/dist/index.js.map +1 -1
- package/dist/nodeid_type.d.ts +13 -0
- package/dist/nodeid_type.js +19 -0
- package/dist/nodeid_type.js.map +1 -0
- package/dist/parameters.d.ts +3 -0
- package/dist/parameters.js +7 -0
- package/dist/parameters.js.map +1 -0
- package/dist/register_class_definition.d.ts +3 -0
- package/dist/register_class_definition.js +9 -0
- package/dist/register_class_definition.js.map +1 -0
- package/dist/schema_helpers.d.ts +24 -0
- package/dist/schema_helpers.js +100 -0
- package/dist/schema_helpers.js.map +1 -0
- package/dist/structured_type_schema.d.ts +44 -0
- package/dist/structured_type_schema.js +279 -0
- package/dist/structured_type_schema.js.map +1 -0
- package/dist/types.d.ts +151 -110
- package/dist/types.js +9 -51
- package/dist/types.js.map +1 -1
- package/package.json +7 -6
- package/source/{factories_baseobject.ts → base_ua_object.ts} +48 -44
- package/source/{factories_basic_type.ts → basic_type.ts} +7 -28
- package/source/{factories_builtin_types.ts → builtin_types.ts} +111 -89
- package/source/{factories_builtin_types_special.ts → builtin_types_special.ts} +2 -2
- package/source/datatype_factory.ts +44 -47
- package/source/encode_decode.ts +37 -0
- package/source/{factories_enumerations.ts → enumerations.ts} +6 -4
- package/source/get_built_in_type.ts +0 -0
- package/source/{factories_factories.ts → get_standard_data_type_factory.ts} +7 -25
- package/source/get_structured_type_schema.ts +10 -0
- package/source/{factories_id_generator.ts → id_generator.ts} +0 -0
- package/source/index.ts +14 -11
- package/source/nodeid_type.ts +17 -0
- package/source/parameters.ts +3 -0
- package/source/register_class_definition.ts +11 -0
- package/source/{factories_schema_helpers.ts → schema_helpers.ts} +15 -37
- package/source/{factories_structuredTypeSchema.ts → structured_type_schema.ts} +37 -36
- package/source/types.ts +104 -79
- package/source/constructor_type.ts +0 -18
package/source/types.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-factory
|
|
3
3
|
*/
|
|
4
|
-
import { assert } from "node-opcua-assert";
|
|
5
4
|
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
6
|
-
import { Enum
|
|
7
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
8
|
-
|
|
5
|
+
import { Enum } from "node-opcua-enum";
|
|
6
|
+
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
|
|
7
|
+
|
|
8
|
+
export enum FieldCategory {
|
|
9
|
+
enumeration = "enumeration",
|
|
10
|
+
complex = "complex",
|
|
11
|
+
basic = "basic"
|
|
12
|
+
}
|
|
9
13
|
|
|
10
14
|
// ------------------
|
|
11
15
|
// @brief CommonInterface
|
|
@@ -15,44 +19,93 @@ import { ConstructorFunc } from "./constructor_type";
|
|
|
15
19
|
//
|
|
16
20
|
export interface CommonInterface {
|
|
17
21
|
name: string;
|
|
22
|
+
defaultValue?: any;
|
|
18
23
|
|
|
19
24
|
encode?: (value: any, stream: OutputBinaryStream) => void;
|
|
20
25
|
decode?: (stream: BinaryStream) => any;
|
|
21
|
-
|
|
22
26
|
coerce?: (value: any) => any;
|
|
27
|
+
|
|
23
28
|
toJSON?: (value: any) => any;
|
|
29
|
+
category: FieldCategory;
|
|
30
|
+
|
|
24
31
|
random?: () => any;
|
|
25
32
|
validate?: (value: any) => void;
|
|
33
|
+
computer_default_value(defaultValue: any): any;
|
|
34
|
+
subType: string;
|
|
35
|
+
isAbstract: boolean;
|
|
26
36
|
|
|
27
|
-
|
|
37
|
+
isSubTypeOf(type: CommonInterface): boolean;
|
|
38
|
+
}
|
|
28
39
|
|
|
29
|
-
|
|
40
|
+
export interface FieldInterfaceOptions {
|
|
41
|
+
name: string;
|
|
42
|
+
defaultValue?: any | DefaultValueFunc;
|
|
43
|
+
|
|
44
|
+
fieldType: string;
|
|
45
|
+
isArray?: boolean;
|
|
46
|
+
documentation?: string;
|
|
47
|
+
category?: FieldCategory;
|
|
48
|
+
schema?: CommonInterface;
|
|
49
|
+
switchBit?: number; // the bit number
|
|
50
|
+
switchValue?: number;
|
|
51
|
+
allowSubType?: boolean;
|
|
52
|
+
dataType?: NodeId;
|
|
53
|
+
basicDataType?: number;
|
|
30
54
|
}
|
|
31
55
|
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
56
|
+
export type Func1<T> = (value: any, field: StructuredTypeField, data: T, args?: any) => void;
|
|
57
|
+
export interface DecodeDebugOptions {
|
|
58
|
+
tracer: any;
|
|
59
|
+
name: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface IBaseUAObject {
|
|
63
|
+
schema: IStructuredTypeSchema;
|
|
64
|
+
encode(stream: OutputBinaryStream): void;
|
|
65
|
+
decode(stream: BinaryStream): void;
|
|
66
|
+
binaryStoreSize(): number;
|
|
67
|
+
toString(...args: any[]): string;
|
|
68
|
+
isValid(): boolean;
|
|
69
|
+
explore(): string;
|
|
70
|
+
applyOnAllFields<T>(func: Func1<T>, data: T): void;
|
|
71
|
+
toJSON(): any;
|
|
72
|
+
decodeDebug(stream: BinaryStream, options: DecodeDebugOptions): void;
|
|
73
|
+
clone(): IBaseUAObject;
|
|
74
|
+
}
|
|
75
|
+
type BaseUAObjectConstructable = new (options?: any) => IBaseUAObject;
|
|
76
|
+
export type ConstructorFunc = BaseUAObjectConstructable;
|
|
77
|
+
// new (...args: any[]) => BaseUAObjectConstructable;
|
|
78
|
+
|
|
79
|
+
export interface ConstructorFuncWithSchema extends ConstructorFunc {
|
|
80
|
+
schema: IStructuredTypeSchema;
|
|
81
|
+
possibleFields: string[];
|
|
82
|
+
encodingDefaultBinary: ExpandedNodeId;
|
|
83
|
+
encodingDefaultXml: ExpandedNodeId;
|
|
84
|
+
encodingDefaultJson?: ExpandedNodeId;
|
|
36
85
|
}
|
|
37
86
|
|
|
38
87
|
export interface StructuredTypeField {
|
|
39
|
-
|
|
88
|
+
|
|
89
|
+
name: string; // the name that may have been lowercased
|
|
90
|
+
originalName: string; // the orignal name from the raw OPCUA description
|
|
40
91
|
|
|
41
92
|
fieldType: string;
|
|
42
|
-
|
|
43
93
|
isArray?: boolean;
|
|
44
94
|
documentation?: string;
|
|
45
95
|
category: FieldCategory;
|
|
96
|
+
defaultValue?: any | DefaultValueFunc;
|
|
46
97
|
schema: CommonInterface;
|
|
98
|
+
switchBit?: number; // the bit number
|
|
99
|
+
switchValue?: number;
|
|
100
|
+
allowSubType?: boolean;
|
|
101
|
+
dataType?: NodeId;
|
|
102
|
+
basicDataType?: number; // DataType
|
|
47
103
|
|
|
48
104
|
fieldTypeConstructor?: ConstructorFunc;
|
|
105
|
+
|
|
49
106
|
subType?: string;
|
|
50
|
-
defaultValue?: any;
|
|
51
107
|
validate?: (value: any) => boolean;
|
|
52
108
|
decode?: (stream: BinaryStream) => any;
|
|
53
|
-
|
|
54
|
-
switchBit?: number; // the bit number
|
|
55
|
-
switchValue?: number;
|
|
56
109
|
}
|
|
57
110
|
|
|
58
111
|
// tslint:disable:no-empty-interface
|
|
@@ -72,18 +125,6 @@ export type FieldType = FieldEnumeration | FieldComplex | FieldBasic;
|
|
|
72
125
|
|
|
73
126
|
export type DefaultValueFunc = () => any;
|
|
74
127
|
|
|
75
|
-
export interface FieldInterfaceOptions {
|
|
76
|
-
name: string;
|
|
77
|
-
fieldType: string;
|
|
78
|
-
isArray?: boolean;
|
|
79
|
-
documentation?: string;
|
|
80
|
-
category?: FieldCategory;
|
|
81
|
-
defaultValue?: any | DefaultValueFunc;
|
|
82
|
-
schema?: any;
|
|
83
|
-
switchBit?: number; // the bit number
|
|
84
|
-
switchValue?: number;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
128
|
export interface StructuredTypeOptions {
|
|
88
129
|
name: string;
|
|
89
130
|
id?: number | NodeId;
|
|
@@ -97,6 +138,8 @@ export interface StructuredTypeOptions {
|
|
|
97
138
|
|
|
98
139
|
export interface TypeSchemaConstructorOptions {
|
|
99
140
|
name: string;
|
|
141
|
+
subType?: string;
|
|
142
|
+
isAbstract?: boolean;
|
|
100
143
|
category?: FieldCategory;
|
|
101
144
|
defaultValue?: any;
|
|
102
145
|
encode?: (value: any, stream: OutputBinaryStream) => void;
|
|
@@ -104,13 +147,20 @@ export interface TypeSchemaConstructorOptions {
|
|
|
104
147
|
coerce?: (value: any) => any;
|
|
105
148
|
}
|
|
106
149
|
|
|
107
|
-
export interface
|
|
108
|
-
subType: string;
|
|
150
|
+
export interface BasicTypeDefinitionOptionsB extends TypeSchemaConstructorOptions {
|
|
109
151
|
toJSON?: (value: any) => any;
|
|
110
152
|
random?: () => any;
|
|
111
153
|
validate?: (value: any) => void;
|
|
112
154
|
}
|
|
113
155
|
|
|
156
|
+
export interface BasicTypeDefinitionOptionsBase extends BasicTypeDefinitionOptionsB {
|
|
157
|
+
/** */
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface BasicTypeDefinitionOptions extends BasicTypeDefinitionOptionsB {
|
|
161
|
+
subType: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
114
164
|
export interface BasicTypeDefinition extends CommonInterface {
|
|
115
165
|
subType: string;
|
|
116
166
|
}
|
|
@@ -118,57 +168,32 @@ export interface BasicTypeDefinition extends CommonInterface {
|
|
|
118
168
|
export interface BuiltInTypeDefinition extends BasicTypeDefinition {}
|
|
119
169
|
|
|
120
170
|
export interface EnumerationDefinition extends CommonInterface {
|
|
121
|
-
|
|
171
|
+
// enumValues: any;
|
|
122
172
|
typedEnum: Enum;
|
|
123
173
|
documentation?: string;
|
|
124
174
|
}
|
|
125
175
|
|
|
126
|
-
export type TypeDefinition = BuiltInTypeDefinition | EnumerationDefinition | BasicTypeDefinition |
|
|
176
|
+
export type TypeDefinition = BuiltInTypeDefinition | EnumerationDefinition | BasicTypeDefinition | CommonInterface;
|
|
127
177
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.name = options.name;
|
|
150
|
-
|
|
151
|
-
for (const prop in options) {
|
|
152
|
-
if (Object.prototype.hasOwnProperty.call(options, prop)) {
|
|
153
|
-
(this as any)[prop] = (options as any)[prop];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @method computer_default_value
|
|
160
|
-
* @param defaultValue {*} the default value
|
|
161
|
-
* @return {*}
|
|
162
|
-
*/
|
|
163
|
-
public computer_default_value(defaultValue: unknown): any {
|
|
164
|
-
if (defaultValue === undefined) {
|
|
165
|
-
defaultValue = this.defaultValue;
|
|
166
|
-
}
|
|
167
|
-
if (typeof defaultValue === "function") {
|
|
168
|
-
// be careful not to cache this value , it must be call each time to make sure
|
|
169
|
-
// we do not end up with the same value/instance twice.
|
|
170
|
-
defaultValue = defaultValue();
|
|
171
|
-
}
|
|
172
|
-
return defaultValue;
|
|
173
|
-
}
|
|
178
|
+
export interface IStructuredTypeSchema extends CommonInterface {
|
|
179
|
+
fields: FieldType[];
|
|
180
|
+
id: NodeId;
|
|
181
|
+
dataTypeNodeId: NodeId;
|
|
182
|
+
|
|
183
|
+
baseType: string;
|
|
184
|
+
_possibleFields: string[];
|
|
185
|
+
_baseSchema: IStructuredTypeSchema | null;
|
|
186
|
+
|
|
187
|
+
documentation?: string;
|
|
188
|
+
|
|
189
|
+
isValid?: (options: any) => boolean;
|
|
190
|
+
|
|
191
|
+
decodeDebug?: (stream: BinaryStream, options: any) => any;
|
|
192
|
+
constructHook?: (options: any) => any;
|
|
193
|
+
|
|
194
|
+
encodingDefaultBinary?: ExpandedNodeId;
|
|
195
|
+
encodingDefaultXml?: ExpandedNodeId;
|
|
196
|
+
encodingDefaultJson?: ExpandedNodeId;
|
|
197
|
+
|
|
198
|
+
bitFields?: any[];
|
|
174
199
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node-opcua-factory
|
|
3
|
-
*/
|
|
4
|
-
import { ExpandedNodeId } from "node-opcua-nodeid";
|
|
5
|
-
|
|
6
|
-
import { BaseUAObject } from "./factories_baseobject";
|
|
7
|
-
import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
|
|
8
|
-
|
|
9
|
-
type BaseUAObjectConstructable = new (options?: any) => BaseUAObject;
|
|
10
|
-
export type ConstructorFunc = BaseUAObjectConstructable;
|
|
11
|
-
// new (...args: any[]) => BaseUAObjectConstructable;
|
|
12
|
-
|
|
13
|
-
export interface ConstructorFuncWithSchema extends ConstructorFunc {
|
|
14
|
-
schema: StructuredTypeSchema;
|
|
15
|
-
possibleFields: string[];
|
|
16
|
-
encodingDefaultBinary: ExpandedNodeId;
|
|
17
|
-
encodingDefaultXml: ExpandedNodeId;
|
|
18
|
-
}
|