node-opcua-factory 2.73.1 → 2.76.0

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 (69) hide show
  1. package/LICENSE +3 -1
  2. package/dist/base_ua_object.d.ts +53 -53
  3. package/dist/base_ua_object.js +535 -535
  4. package/dist/basic_type.d.ts +40 -40
  5. package/dist/basic_type.js +118 -118
  6. package/dist/builtin_types.d.ts +46 -46
  7. package/dist/builtin_types.js +283 -283
  8. package/dist/builtin_types_special.d.ts +5 -5
  9. package/dist/builtin_types_special.js +45 -45
  10. package/dist/datatype_factory.d.ts +36 -36
  11. package/dist/datatype_factory.js +307 -305
  12. package/dist/datatype_factory.js.map +1 -1
  13. package/dist/encode_decode.d.ts +9 -9
  14. package/dist/encode_decode.js +39 -39
  15. package/dist/enumerations.d.ts +32 -32
  16. package/dist/enumerations.js +77 -77
  17. package/dist/get_built_in_type.js +1 -1
  18. package/dist/get_standard_data_type_factory.d.ts +12 -12
  19. package/dist/get_standard_data_type_factory.js +34 -34
  20. package/dist/get_structured_type_schema.d.ts +4 -4
  21. package/dist/get_structured_type_schema.js +12 -12
  22. package/dist/id_generator.d.ts +3 -3
  23. package/dist/id_generator.js +21 -21
  24. package/dist/index.d.ts +18 -18
  25. package/dist/index.js +34 -34
  26. package/dist/nodeid_type.d.ts +13 -13
  27. package/dist/nodeid_type.js +18 -18
  28. package/dist/parameters.d.ts +3 -3
  29. package/dist/parameters.js +6 -6
  30. package/dist/register_class_definition.d.ts +3 -3
  31. package/dist/register_class_definition.js +8 -8
  32. package/dist/schema_helpers.d.ts +24 -24
  33. package/dist/schema_helpers.js +99 -99
  34. package/dist/structured_type_schema.d.ts +44 -44
  35. package/dist/structured_type_schema.js +278 -278
  36. package/dist/types.d.ts +151 -151
  37. package/dist/types.js +9 -9
  38. package/package.json +15 -12
  39. package/source/datatype_factory.ts +8 -5
  40. package/dist/constructor_type.d.ts +0 -15
  41. package/dist/constructor_type.js +0 -3
  42. package/dist/constructor_type.js.map +0 -1
  43. package/dist/factories_baseobject.d.ts +0 -56
  44. package/dist/factories_baseobject.js +0 -535
  45. package/dist/factories_baseobject.js.map +0 -1
  46. package/dist/factories_basic_type.d.ts +0 -40
  47. package/dist/factories_basic_type.js +0 -136
  48. package/dist/factories_basic_type.js.map +0 -1
  49. package/dist/factories_builtin_types.d.ts +0 -32
  50. package/dist/factories_builtin_types.js +0 -262
  51. package/dist/factories_builtin_types.js.map +0 -1
  52. package/dist/factories_builtin_types_special.d.ts +0 -5
  53. package/dist/factories_builtin_types_special.js +0 -46
  54. package/dist/factories_builtin_types_special.js.map +0 -1
  55. package/dist/factories_enumerations.d.ts +0 -31
  56. package/dist/factories_enumerations.js +0 -78
  57. package/dist/factories_enumerations.js.map +0 -1
  58. package/dist/factories_factories.d.ts +0 -17
  59. package/dist/factories_factories.js +0 -54
  60. package/dist/factories_factories.js.map +0 -1
  61. package/dist/factories_id_generator.d.ts +0 -3
  62. package/dist/factories_id_generator.js +0 -22
  63. package/dist/factories_id_generator.js.map +0 -1
  64. package/dist/factories_schema_helpers.d.ts +0 -27
  65. package/dist/factories_schema_helpers.js +0 -122
  66. package/dist/factories_schema_helpers.js.map +0 -1
  67. package/dist/factories_structuredTypeSchema.d.ts +0 -45
  68. package/dist/factories_structuredTypeSchema.js +0 -277
  69. package/dist/factories_structuredTypeSchema.js.map +0 -1
@@ -1,284 +1,284 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findBuiltInType = exports.hasBuiltInType = exports.getBuiltInType = exports.unregisterType = exports.registerBuiltInType = exports.registerType = exports.BasicTypeSchema = exports.TypeSchemaBase = void 0;
4
- /**
5
- * @module node-opcua-factory
6
- */
7
- const node_opcua_assert_1 = require("node-opcua-assert");
8
- const node_opcua_basic_types_1 = require("node-opcua-basic-types");
9
- const node_opcua_constants_1 = require("node-opcua-constants");
10
- const node_opcua_guid_1 = require("node-opcua-guid");
11
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
12
- const node_opcua_status_code_1 = require("node-opcua-status-code");
13
- const encode_decode_1 = require("./encode_decode");
14
- const types_1 = require("./types");
15
- /**
16
- * @class TypeSchemaBase
17
- * @param options {Object}
18
- * @constructor
19
- * create a new type Schema
20
- */
21
- class TypeSchemaBase {
22
- constructor(options) {
23
- (0, node_opcua_assert_1.assert)(options.category !== null);
24
- this.encode = options.encode || undefined;
25
- this.decode = options.decode || undefined;
26
- this.coerce = options.coerce;
27
- this.category = options.category || types_1.FieldCategory.basic;
28
- this.name = options.name;
29
- for (const prop in options) {
30
- if (Object.prototype.hasOwnProperty.call(options, prop)) {
31
- this[prop] = options[prop];
32
- }
33
- }
34
- this.subType = options.subType || "";
35
- this.isAbstract = options.isAbstract || false;
36
- }
37
- /**
38
- * @method computer_default_value
39
- * @param defaultValue {*} the default value
40
- * @return {*}
41
- */
42
- computer_default_value(defaultValue) {
43
- if (defaultValue === undefined) {
44
- defaultValue = this.defaultValue;
45
- }
46
- if (typeof defaultValue === "function") {
47
- // be careful not to cache this value , it must be call each time to make sure
48
- // we do not end up with the same value/instance twice.
49
- defaultValue = defaultValue();
50
- }
51
- return defaultValue;
52
- }
53
- getBaseType() {
54
- if (!this.subType)
55
- return null;
56
- return getBuiltInType(this.subType);
57
- }
58
- isSubTypeOf(type) {
59
- if (this.name === type.name) {
60
- return true;
61
- }
62
- const baseType = this.getBaseType();
63
- if (!baseType) {
64
- return false;
65
- }
66
- return baseType.isSubTypeOf(type);
67
- }
68
- }
69
- exports.TypeSchemaBase = TypeSchemaBase;
70
- class BasicTypeSchema extends TypeSchemaBase {
71
- constructor(options) {
72
- super(options);
73
- this.subType = options.subType;
74
- this.isAbstract = options.isAbstract || false;
75
- this.encode = options.encode || encode_decode_1.defaultEncode;
76
- this.decode = options.decode || encode_decode_1.defaultDecode;
77
- }
78
- }
79
- exports.BasicTypeSchema = BasicTypeSchema;
80
- // there are 4 types of DataTypes in opcua:
81
- // Built-In DataType
82
- // Simple DataType
83
- // Complex DataType
84
- // Enumeration
85
- const defaultXmlElement = "";
86
- // Built-In Type
87
- const _defaultType = [
88
- // Built-in DataTypes ( see OPCUA Part III v1.02 - $5.8.2 )
89
- {
90
- name: "Null",
91
- decode: encode_decode_1.decodeNull,
92
- encode: encode_decode_1.encodeNull,
93
- defaultValue: null
94
- },
95
- {
96
- // special case
97
- name: "Any",
98
- decode: encode_decode_1.decodeAny,
99
- encode: encode_decode_1.encodeAny
100
- },
101
- {
102
- name: "Boolean",
103
- decode: node_opcua_basic_types_1.decodeBoolean,
104
- encode: node_opcua_basic_types_1.encodeBoolean,
105
- coerce: node_opcua_basic_types_1.coerceBoolean,
106
- defaultValue: false
107
- },
108
- { name: "Number", isAbstract: true },
109
- { name: "Integer", subType: "Number", isAbstract: true },
110
- { name: "UInteger", subType: "Number", isAbstract: true },
111
- { name: "SByte", subType: "Integer", encode: node_opcua_basic_types_1.encodeSByte, decode: node_opcua_basic_types_1.decodeSByte, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceSByte },
112
- { name: "Byte", subType: "UInteger", encode: node_opcua_basic_types_1.encodeByte, decode: node_opcua_basic_types_1.decodeByte, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceByte },
113
- { name: "Int16", subType: "Integer", encode: node_opcua_basic_types_1.encodeInt16, decode: node_opcua_basic_types_1.decodeInt16, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceInt16 },
114
- { name: "UInt16", subType: "UInteger", encode: node_opcua_basic_types_1.encodeUInt16, decode: node_opcua_basic_types_1.decodeUInt16, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceUInt16 },
115
- { name: "Int32", subType: "Integer", encode: node_opcua_basic_types_1.encodeInt32, decode: node_opcua_basic_types_1.decodeInt32, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceInt32 },
116
- { name: "UInt32", subType: "UInteger", encode: node_opcua_basic_types_1.encodeUInt32, decode: node_opcua_basic_types_1.decodeUInt32, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceUInt32 },
117
- {
118
- name: "Int64",
119
- subType: "Integer",
120
- decode: node_opcua_basic_types_1.decodeInt64,
121
- encode: node_opcua_basic_types_1.encodeInt64,
122
- coerce: node_opcua_basic_types_1.coerceInt64,
123
- defaultValue: (0, node_opcua_basic_types_1.coerceInt64)(0)
124
- },
125
- {
126
- name: "UInt64",
127
- subType: "UInteger",
128
- decode: node_opcua_basic_types_1.decodeUInt64,
129
- encode: node_opcua_basic_types_1.encodeUInt64,
130
- coerce: node_opcua_basic_types_1.coerceUInt64,
131
- defaultValue: (0, node_opcua_basic_types_1.coerceUInt64)(0)
132
- },
133
- {
134
- name: "Float",
135
- subType: "Number",
136
- decode: node_opcua_basic_types_1.decodeFloat,
137
- encode: node_opcua_basic_types_1.encodeFloat,
138
- coerce: node_opcua_basic_types_1.coerceFloat,
139
- defaultValue: 0.0
140
- },
141
- {
142
- name: "Double",
143
- subType: "Number",
144
- decode: node_opcua_basic_types_1.decodeDouble,
145
- encode: node_opcua_basic_types_1.encodeDouble,
146
- coerce: node_opcua_basic_types_1.coerceDouble,
147
- defaultValue: 0.0
148
- },
149
- {
150
- name: "String",
151
- decode: node_opcua_basic_types_1.decodeString,
152
- encode: node_opcua_basic_types_1.encodeString,
153
- defaultValue: ""
154
- },
155
- // OPC Unified Architecture, part 3.0 $8.26 page 67
156
- {
157
- name: "DateTime",
158
- decode: node_opcua_basic_types_1.decodeDateTime,
159
- encode: node_opcua_basic_types_1.encodeDateTime,
160
- coerce: node_opcua_basic_types_1.coerceDateTime,
161
- defaultValue: () => node_opcua_basic_types_1.minDate
162
- },
163
- {
164
- name: "Guid",
165
- decode: node_opcua_basic_types_1.decodeGuid,
166
- encode: node_opcua_basic_types_1.encodeGuid,
167
- defaultValue: node_opcua_guid_1.emptyGuid
168
- },
169
- {
170
- name: "ByteString",
171
- decode: node_opcua_basic_types_1.decodeByteString,
172
- encode: node_opcua_basic_types_1.encodeByteString,
173
- coerce: node_opcua_basic_types_1.coerceByteString,
174
- defaultValue: null,
175
- toJSON: encode_decode_1.toJSONGuid
176
- },
177
- {
178
- name: "XmlElement",
179
- decode: node_opcua_basic_types_1.decodeString,
180
- encode: node_opcua_basic_types_1.encodeString,
181
- defaultValue: defaultXmlElement
182
- },
183
- // see OPCUA Part 3 - V1.02 $8.2.1
184
- {
185
- name: "NodeId",
186
- decode: node_opcua_basic_types_1.decodeNodeId,
187
- encode: node_opcua_basic_types_1.encodeNodeId,
188
- coerce: node_opcua_basic_types_1.coerceNodeId,
189
- defaultValue: node_opcua_nodeid_1.makeNodeId
190
- },
191
- {
192
- name: "ExpandedNodeId",
193
- decode: node_opcua_basic_types_1.decodeExpandedNodeId,
194
- encode: node_opcua_basic_types_1.encodeExpandedNodeId,
195
- coerce: node_opcua_basic_types_1.coerceExpandedNodeId,
196
- defaultValue: node_opcua_nodeid_1.makeExpandedNodeId
197
- },
198
- // ----------------------------------------------------------------------------------------
199
- // Simple DataTypes
200
- // ( see OPCUA Part III v1.02 - $5.8.2 )
201
- // Simple DataTypes are subtypes of the Built-in DataTypes. They are handled on the wire like the
202
- // Built-in DataType, i.e. they cannot be distinguished on the wire from their Built-in super types.
203
- // Since they are handled like Built-in DataTypes regarding the encoding they cannot have encodings
204
- // defined in the AddressSpace. Clients can read the DataType Attribute of a Variable or VariableType to
205
- // identify the Simple DataType of the Value Attribute. An example of a Simple DataType is Duration. It
206
- // is handled on the wire as a Double but the Client can read the DataType Attribute and thus interpret
207
- // the value as defined by Duration
208
- //
209
- // OPC Unified Architecture, part 4.0 $7.13
210
- // IntegerID: This primitive data type is an UInt32 that is used as an identifier, such as a handle. All values,
211
- // except for 0, are valid.
212
- {
213
- name: "IntegerId",
214
- decode: node_opcua_basic_types_1.decodeUInt32,
215
- encode: node_opcua_basic_types_1.encodeUInt32,
216
- defaultValue: 0xffffffff
217
- },
218
- // The StatusCode is a 32-bit unsigned integer. The top 16 bits represent the numeric value of the
219
- // code that shall be used for detecting specific errors or conditions. The bottom 16 bits are bit flags
220
- // that contain additional information but do not affect the meaning of the StatusCode.
221
- // 7.33 Part 4 - P 143
222
- {
223
- name: "StatusCode",
224
- decode: node_opcua_status_code_1.decodeStatusCode,
225
- encode: node_opcua_status_code_1.encodeStatusCode,
226
- coerce: node_opcua_status_code_1.coerceStatusCode,
227
- defaultValue: node_opcua_status_code_1.StatusCodes.Good
228
- }
229
- ];
230
- // populate the default type map
231
- const _defaultTypeMap = new Map();
232
- _defaultType.forEach(registerType);
233
- /**
234
- * @method registerType
235
- * @param schema {TypeSchemaBase}
236
- */
237
- function registerType(schema) {
238
- if (!schema.isAbstract) {
239
- (0, node_opcua_assert_1.assert)(schema.encode);
240
- (0, node_opcua_assert_1.assert)(schema.decode);
241
- }
242
- schema.category = types_1.FieldCategory.basic;
243
- schema.subType = schema.subType || "";
244
- if (schema.name !== "Null" && schema.name !== "Any" && schema.name !== "Variant" && schema.name !== "ExtensionObject") {
245
- const dataType = node_opcua_constants_1.DataTypeIds[schema.name];
246
- if (!dataType) {
247
- throw new Error("registerType : dataType " + schema.name + " is not defined");
248
- }
249
- }
250
- const definition = new BasicTypeSchema(schema);
251
- _defaultTypeMap.set(schema.name, definition);
252
- }
253
- exports.registerType = registerType;
254
- exports.registerBuiltInType = registerType;
255
- function unregisterType(typeName) {
256
- _defaultTypeMap.delete(typeName);
257
- }
258
- exports.unregisterType = unregisterType;
259
- function getBuiltInType(name) {
260
- const typeSchema = _defaultTypeMap.get(name);
261
- if (!typeSchema) {
262
- throw new Error("Cannot find schema for simple type " + name);
263
- }
264
- return typeSchema;
265
- }
266
- exports.getBuiltInType = getBuiltInType;
267
- function hasBuiltInType(name) {
268
- return _defaultTypeMap.has(name);
269
- }
270
- exports.hasBuiltInType = hasBuiltInType;
271
- /** */
272
- function findBuiltInType(dataTypeName) {
273
- (0, node_opcua_assert_1.assert)(typeof dataTypeName === "string", "findBuiltInType : expecting a string " + dataTypeName);
274
- const t = getBuiltInType(dataTypeName);
275
- if (t.subType && t.subType !== t.name /* avoid infinite recursion */) {
276
- const st = getBuiltInType(t.subType);
277
- if (!st.isAbstract) {
278
- return findBuiltInType(t.subType);
279
- }
280
- }
281
- return t;
282
- }
283
- exports.findBuiltInType = findBuiltInType;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findBuiltInType = exports.hasBuiltInType = exports.getBuiltInType = exports.unregisterType = exports.registerBuiltInType = exports.registerType = exports.BasicTypeSchema = exports.TypeSchemaBase = void 0;
4
+ /**
5
+ * @module node-opcua-factory
6
+ */
7
+ const node_opcua_assert_1 = require("node-opcua-assert");
8
+ const node_opcua_basic_types_1 = require("node-opcua-basic-types");
9
+ const node_opcua_constants_1 = require("node-opcua-constants");
10
+ const node_opcua_guid_1 = require("node-opcua-guid");
11
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
12
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
13
+ const encode_decode_1 = require("./encode_decode");
14
+ const types_1 = require("./types");
15
+ /**
16
+ * @class TypeSchemaBase
17
+ * @param options {Object}
18
+ * @constructor
19
+ * create a new type Schema
20
+ */
21
+ class TypeSchemaBase {
22
+ constructor(options) {
23
+ (0, node_opcua_assert_1.assert)(options.category !== null);
24
+ this.encode = options.encode || undefined;
25
+ this.decode = options.decode || undefined;
26
+ this.coerce = options.coerce;
27
+ this.category = options.category || types_1.FieldCategory.basic;
28
+ this.name = options.name;
29
+ for (const prop in options) {
30
+ if (Object.prototype.hasOwnProperty.call(options, prop)) {
31
+ this[prop] = options[prop];
32
+ }
33
+ }
34
+ this.subType = options.subType || "";
35
+ this.isAbstract = options.isAbstract || false;
36
+ }
37
+ /**
38
+ * @method computer_default_value
39
+ * @param defaultValue {*} the default value
40
+ * @return {*}
41
+ */
42
+ computer_default_value(defaultValue) {
43
+ if (defaultValue === undefined) {
44
+ defaultValue = this.defaultValue;
45
+ }
46
+ if (typeof defaultValue === "function") {
47
+ // be careful not to cache this value , it must be call each time to make sure
48
+ // we do not end up with the same value/instance twice.
49
+ defaultValue = defaultValue();
50
+ }
51
+ return defaultValue;
52
+ }
53
+ getBaseType() {
54
+ if (!this.subType)
55
+ return null;
56
+ return getBuiltInType(this.subType);
57
+ }
58
+ isSubTypeOf(type) {
59
+ if (this.name === type.name) {
60
+ return true;
61
+ }
62
+ const baseType = this.getBaseType();
63
+ if (!baseType) {
64
+ return false;
65
+ }
66
+ return baseType.isSubTypeOf(type);
67
+ }
68
+ }
69
+ exports.TypeSchemaBase = TypeSchemaBase;
70
+ class BasicTypeSchema extends TypeSchemaBase {
71
+ constructor(options) {
72
+ super(options);
73
+ this.subType = options.subType;
74
+ this.isAbstract = options.isAbstract || false;
75
+ this.encode = options.encode || encode_decode_1.defaultEncode;
76
+ this.decode = options.decode || encode_decode_1.defaultDecode;
77
+ }
78
+ }
79
+ exports.BasicTypeSchema = BasicTypeSchema;
80
+ // there are 4 types of DataTypes in opcua:
81
+ // Built-In DataType
82
+ // Simple DataType
83
+ // Complex DataType
84
+ // Enumeration
85
+ const defaultXmlElement = "";
86
+ // Built-In Type
87
+ const _defaultType = [
88
+ // Built-in DataTypes ( see OPCUA Part III v1.02 - $5.8.2 )
89
+ {
90
+ name: "Null",
91
+ decode: encode_decode_1.decodeNull,
92
+ encode: encode_decode_1.encodeNull,
93
+ defaultValue: null
94
+ },
95
+ {
96
+ // special case
97
+ name: "Any",
98
+ decode: encode_decode_1.decodeAny,
99
+ encode: encode_decode_1.encodeAny
100
+ },
101
+ {
102
+ name: "Boolean",
103
+ decode: node_opcua_basic_types_1.decodeBoolean,
104
+ encode: node_opcua_basic_types_1.encodeBoolean,
105
+ coerce: node_opcua_basic_types_1.coerceBoolean,
106
+ defaultValue: false
107
+ },
108
+ { name: "Number", isAbstract: true },
109
+ { name: "Integer", subType: "Number", isAbstract: true },
110
+ { name: "UInteger", subType: "Number", isAbstract: true },
111
+ { name: "SByte", subType: "Integer", encode: node_opcua_basic_types_1.encodeSByte, decode: node_opcua_basic_types_1.decodeSByte, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceSByte },
112
+ { name: "Byte", subType: "UInteger", encode: node_opcua_basic_types_1.encodeByte, decode: node_opcua_basic_types_1.decodeByte, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceByte },
113
+ { name: "Int16", subType: "Integer", encode: node_opcua_basic_types_1.encodeInt16, decode: node_opcua_basic_types_1.decodeInt16, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceInt16 },
114
+ { name: "UInt16", subType: "UInteger", encode: node_opcua_basic_types_1.encodeUInt16, decode: node_opcua_basic_types_1.decodeUInt16, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceUInt16 },
115
+ { name: "Int32", subType: "Integer", encode: node_opcua_basic_types_1.encodeInt32, decode: node_opcua_basic_types_1.decodeInt32, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceInt32 },
116
+ { name: "UInt32", subType: "UInteger", encode: node_opcua_basic_types_1.encodeUInt32, decode: node_opcua_basic_types_1.decodeUInt32, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceUInt32 },
117
+ {
118
+ name: "Int64",
119
+ subType: "Integer",
120
+ decode: node_opcua_basic_types_1.decodeInt64,
121
+ encode: node_opcua_basic_types_1.encodeInt64,
122
+ coerce: node_opcua_basic_types_1.coerceInt64,
123
+ defaultValue: (0, node_opcua_basic_types_1.coerceInt64)(0)
124
+ },
125
+ {
126
+ name: "UInt64",
127
+ subType: "UInteger",
128
+ decode: node_opcua_basic_types_1.decodeUInt64,
129
+ encode: node_opcua_basic_types_1.encodeUInt64,
130
+ coerce: node_opcua_basic_types_1.coerceUInt64,
131
+ defaultValue: (0, node_opcua_basic_types_1.coerceUInt64)(0)
132
+ },
133
+ {
134
+ name: "Float",
135
+ subType: "Number",
136
+ decode: node_opcua_basic_types_1.decodeFloat,
137
+ encode: node_opcua_basic_types_1.encodeFloat,
138
+ coerce: node_opcua_basic_types_1.coerceFloat,
139
+ defaultValue: 0.0
140
+ },
141
+ {
142
+ name: "Double",
143
+ subType: "Number",
144
+ decode: node_opcua_basic_types_1.decodeDouble,
145
+ encode: node_opcua_basic_types_1.encodeDouble,
146
+ coerce: node_opcua_basic_types_1.coerceDouble,
147
+ defaultValue: 0.0
148
+ },
149
+ {
150
+ name: "String",
151
+ decode: node_opcua_basic_types_1.decodeString,
152
+ encode: node_opcua_basic_types_1.encodeString,
153
+ defaultValue: ""
154
+ },
155
+ // OPC Unified Architecture, part 3.0 $8.26 page 67
156
+ {
157
+ name: "DateTime",
158
+ decode: node_opcua_basic_types_1.decodeDateTime,
159
+ encode: node_opcua_basic_types_1.encodeDateTime,
160
+ coerce: node_opcua_basic_types_1.coerceDateTime,
161
+ defaultValue: () => node_opcua_basic_types_1.minDate
162
+ },
163
+ {
164
+ name: "Guid",
165
+ decode: node_opcua_basic_types_1.decodeGuid,
166
+ encode: node_opcua_basic_types_1.encodeGuid,
167
+ defaultValue: node_opcua_guid_1.emptyGuid
168
+ },
169
+ {
170
+ name: "ByteString",
171
+ decode: node_opcua_basic_types_1.decodeByteString,
172
+ encode: node_opcua_basic_types_1.encodeByteString,
173
+ coerce: node_opcua_basic_types_1.coerceByteString,
174
+ defaultValue: null,
175
+ toJSON: encode_decode_1.toJSONGuid
176
+ },
177
+ {
178
+ name: "XmlElement",
179
+ decode: node_opcua_basic_types_1.decodeString,
180
+ encode: node_opcua_basic_types_1.encodeString,
181
+ defaultValue: defaultXmlElement
182
+ },
183
+ // see OPCUA Part 3 - V1.02 $8.2.1
184
+ {
185
+ name: "NodeId",
186
+ decode: node_opcua_basic_types_1.decodeNodeId,
187
+ encode: node_opcua_basic_types_1.encodeNodeId,
188
+ coerce: node_opcua_basic_types_1.coerceNodeId,
189
+ defaultValue: node_opcua_nodeid_1.makeNodeId
190
+ },
191
+ {
192
+ name: "ExpandedNodeId",
193
+ decode: node_opcua_basic_types_1.decodeExpandedNodeId,
194
+ encode: node_opcua_basic_types_1.encodeExpandedNodeId,
195
+ coerce: node_opcua_basic_types_1.coerceExpandedNodeId,
196
+ defaultValue: node_opcua_nodeid_1.makeExpandedNodeId
197
+ },
198
+ // ----------------------------------------------------------------------------------------
199
+ // Simple DataTypes
200
+ // ( see OPCUA Part III v1.02 - $5.8.2 )
201
+ // Simple DataTypes are subtypes of the Built-in DataTypes. They are handled on the wire like the
202
+ // Built-in DataType, i.e. they cannot be distinguished on the wire from their Built-in super types.
203
+ // Since they are handled like Built-in DataTypes regarding the encoding they cannot have encodings
204
+ // defined in the AddressSpace. Clients can read the DataType Attribute of a Variable or VariableType to
205
+ // identify the Simple DataType of the Value Attribute. An example of a Simple DataType is Duration. It
206
+ // is handled on the wire as a Double but the Client can read the DataType Attribute and thus interpret
207
+ // the value as defined by Duration
208
+ //
209
+ // OPC Unified Architecture, part 4.0 $7.13
210
+ // IntegerID: This primitive data type is an UInt32 that is used as an identifier, such as a handle. All values,
211
+ // except for 0, are valid.
212
+ {
213
+ name: "IntegerId",
214
+ decode: node_opcua_basic_types_1.decodeUInt32,
215
+ encode: node_opcua_basic_types_1.encodeUInt32,
216
+ defaultValue: 0xffffffff
217
+ },
218
+ // The StatusCode is a 32-bit unsigned integer. The top 16 bits represent the numeric value of the
219
+ // code that shall be used for detecting specific errors or conditions. The bottom 16 bits are bit flags
220
+ // that contain additional information but do not affect the meaning of the StatusCode.
221
+ // 7.33 Part 4 - P 143
222
+ {
223
+ name: "StatusCode",
224
+ decode: node_opcua_status_code_1.decodeStatusCode,
225
+ encode: node_opcua_status_code_1.encodeStatusCode,
226
+ coerce: node_opcua_status_code_1.coerceStatusCode,
227
+ defaultValue: node_opcua_status_code_1.StatusCodes.Good
228
+ }
229
+ ];
230
+ // populate the default type map
231
+ const _defaultTypeMap = new Map();
232
+ _defaultType.forEach(registerType);
233
+ /**
234
+ * @method registerType
235
+ * @param schema {TypeSchemaBase}
236
+ */
237
+ function registerType(schema) {
238
+ if (!schema.isAbstract) {
239
+ (0, node_opcua_assert_1.assert)(schema.encode);
240
+ (0, node_opcua_assert_1.assert)(schema.decode);
241
+ }
242
+ schema.category = types_1.FieldCategory.basic;
243
+ schema.subType = schema.subType || "";
244
+ if (schema.name !== "Null" && schema.name !== "Any" && schema.name !== "Variant" && schema.name !== "ExtensionObject") {
245
+ const dataType = node_opcua_constants_1.DataTypeIds[schema.name];
246
+ if (!dataType) {
247
+ throw new Error("registerType : dataType " + schema.name + " is not defined");
248
+ }
249
+ }
250
+ const definition = new BasicTypeSchema(schema);
251
+ _defaultTypeMap.set(schema.name, definition);
252
+ }
253
+ exports.registerType = registerType;
254
+ exports.registerBuiltInType = registerType;
255
+ function unregisterType(typeName) {
256
+ _defaultTypeMap.delete(typeName);
257
+ }
258
+ exports.unregisterType = unregisterType;
259
+ function getBuiltInType(name) {
260
+ const typeSchema = _defaultTypeMap.get(name);
261
+ if (!typeSchema) {
262
+ throw new Error("Cannot find schema for simple type " + name);
263
+ }
264
+ return typeSchema;
265
+ }
266
+ exports.getBuiltInType = getBuiltInType;
267
+ function hasBuiltInType(name) {
268
+ return _defaultTypeMap.has(name);
269
+ }
270
+ exports.hasBuiltInType = hasBuiltInType;
271
+ /** */
272
+ function findBuiltInType(dataTypeName) {
273
+ (0, node_opcua_assert_1.assert)(typeof dataTypeName === "string", "findBuiltInType : expecting a string " + dataTypeName);
274
+ const t = getBuiltInType(dataTypeName);
275
+ if (t.subType && t.subType !== t.name /* avoid infinite recursion */) {
276
+ const st = getBuiltInType(t.subType);
277
+ if (!st.isAbstract) {
278
+ return findBuiltInType(t.subType);
279
+ }
280
+ }
281
+ return t;
282
+ }
283
+ exports.findBuiltInType = findBuiltInType;
284
284
  //# sourceMappingURL=builtin_types.js.map
@@ -1,5 +1,5 @@
1
- /**
2
- * @module node-opcua-factory
3
- */
4
- import { ConstructorFunc } from "./types";
5
- export declare function registerSpecialVariantEncoder(constructor: ConstructorFunc): void;
1
+ /**
2
+ * @module node-opcua-factory
3
+ */
4
+ import { ConstructorFunc } from "./types";
5
+ export declare function registerSpecialVariantEncoder(constructor: ConstructorFunc): void;