node-opcua-factory 2.71.0 → 2.72.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.
@@ -1,40 +1,40 @@
1
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
- export interface BasicTypeOptions {
3
- name: string;
4
- subType: string;
5
- encode?: (value: any, stream: OutputBinaryStream) => void;
6
- decode?: (stream: BinaryStream) => void;
7
- validate?: (value: any) => boolean;
8
- coerce?: (value: any) => any;
9
- toJSON?: (value: any) => any;
10
- random?: () => any;
11
- defaultValue?: any;
12
- }
13
- /**
14
- * register a Basic Type ,
15
- * A basic type is new entity type that resolved to a SubType
16
- * @example:
17
- *
18
- *
19
- * registerBasicType({name:"Duration" ,subType:"Double"});
20
- *
21
- * @method registerBasicType
22
- * @param schema
23
- * @param schema.name {String}
24
- * @param schema.subType {String} mandatory, the basic type from which the new type derives.
25
- *
26
- * @param [schema.encode] {Function} optional,a specific encoder function to encode an instance of this type.
27
- * @param schema.encode.value {*}
28
- * @param schema.encode.stream {BinaryStream}
29
- *
30
- * @param [schema.decode] optional,a specific decoder function that returns the decode value out of the stream.
31
- * @param [schema.decode.stream] {BinaryStream}
32
- *
33
- * @param [schema.coerce] optional, a method to convert a value into the request type.
34
- * @param schema.coerce.value {*} the value to coerce.
35
- *
36
- * @param [schema.random] optional, a method to construct a random object of this type
37
- *
38
- * @param [schema.toJSON]optional, a method to convert a value into the request type.
39
- */
40
- export declare function registerBasicType(schema: BasicTypeOptions): void;
1
+ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
+ export interface BasicTypeOptions {
3
+ name: string;
4
+ subType: string;
5
+ encode?: (value: any, stream: OutputBinaryStream) => void;
6
+ decode?: (stream: BinaryStream) => void;
7
+ validate?: (value: any) => boolean;
8
+ coerce?: (value: any) => any;
9
+ toJSON?: (value: any) => any;
10
+ random?: () => any;
11
+ defaultValue?: any;
12
+ }
13
+ /**
14
+ * register a Basic Type ,
15
+ * A basic type is new entity type that resolved to a SubType
16
+ * @example:
17
+ *
18
+ *
19
+ * registerBasicType({name:"Duration" ,subType:"Double"});
20
+ *
21
+ * @method registerBasicType
22
+ * @param schema
23
+ * @param schema.name {String}
24
+ * @param schema.subType {String} mandatory, the basic type from which the new type derives.
25
+ *
26
+ * @param [schema.encode] {Function} optional,a specific encoder function to encode an instance of this type.
27
+ * @param schema.encode.value {*}
28
+ * @param schema.encode.stream {BinaryStream}
29
+ *
30
+ * @param [schema.decode] optional,a specific decoder function that returns the decode value out of the stream.
31
+ * @param [schema.decode.stream] {BinaryStream}
32
+ *
33
+ * @param [schema.coerce] optional, a method to convert a value into the request type.
34
+ * @param schema.coerce.value {*} the value to coerce.
35
+ *
36
+ * @param [schema.random] optional, a method to construct a random object of this type
37
+ *
38
+ * @param [schema.toJSON]optional, a method to convert a value into the request type.
39
+ */
40
+ export declare function registerBasicType(schema: BasicTypeOptions): void;
@@ -1,136 +1,136 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerBasicType = 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 factories_builtin_types_1 = require("./factories_builtin_types");
10
- /**
11
- * register a Basic Type ,
12
- * A basic type is new entity type that resolved to a SubType
13
- * @example:
14
- *
15
- *
16
- * registerBasicType({name:"Duration" ,subType:"Double"});
17
- *
18
- * @method registerBasicType
19
- * @param schema
20
- * @param schema.name {String}
21
- * @param schema.subType {String} mandatory, the basic type from which the new type derives.
22
- *
23
- * @param [schema.encode] {Function} optional,a specific encoder function to encode an instance of this type.
24
- * @param schema.encode.value {*}
25
- * @param schema.encode.stream {BinaryStream}
26
- *
27
- * @param [schema.decode] optional,a specific decoder function that returns the decode value out of the stream.
28
- * @param [schema.decode.stream] {BinaryStream}
29
- *
30
- * @param [schema.coerce] optional, a method to convert a value into the request type.
31
- * @param schema.coerce.value {*} the value to coerce.
32
- *
33
- * @param [schema.random] optional, a method to construct a random object of this type
34
- *
35
- * @param [schema.toJSON]optional, a method to convert a value into the request type.
36
- */
37
- function registerBasicType(schema) {
38
- const exists = (0, factories_builtin_types_1.hasBuiltInType)(schema.name);
39
- /* istanbul ignore next */
40
- if (exists) {
41
- // tslint:disable-next-line: no-console
42
- console.log("registerBasicType:", schema);
43
- throw new Error(`Basic Type ${schema.name} already registered`);
44
- }
45
- const name = schema.name;
46
- const t = (0, factories_builtin_types_1.findSimpleType)(schema.subType);
47
- /* istanbul ignore next */
48
- if (!t) {
49
- // tslint:disable-next-line:no-console
50
- throw new Error(" cannot find subtype " + schema.subType);
51
- }
52
- (0, node_opcua_assert_1.assert)(typeof t.decode === "function");
53
- const encodeFunc = schema.encode || t.encode;
54
- (0, node_opcua_assert_1.assert)(typeof encodeFunc === "function");
55
- const decodeFunc = schema.decode || t.decode;
56
- (0, node_opcua_assert_1.assert)(typeof decodeFunc === "function");
57
- const defaultValue = schema.defaultValue === undefined ? t.defaultValue : schema.defaultValue;
58
- // assert(typeof defaultValue === "function");
59
- const coerceFunc = schema.coerce || t.coerce;
60
- const toJSONFunc = schema.toJSON || t.toJSON;
61
- const random = schema.random || defaultValue;
62
- const newSchema = {
63
- name,
64
- subType: schema.subType,
65
- coerce: coerceFunc,
66
- decode: decodeFunc,
67
- encode: encodeFunc,
68
- random,
69
- defaultValue,
70
- toJSON: toJSONFunc
71
- };
72
- (0, factories_builtin_types_1.registerType)(newSchema);
73
- }
74
- exports.registerBasicType = registerBasicType;
75
- // =============================================================================================
76
- // Registering the Basic Type already defined int the OPC-UA Specification
77
- // =============================================================================================
78
- registerBasicType({ name: "Counter", subType: "UInt32" });
79
- // OPC Unified Architecture, part 3.0 $8.13 page 65
80
- registerBasicType({ name: "Duration", subType: "Double" });
81
- registerBasicType({ name: "UAString", subType: "String" });
82
- registerBasicType({ name: "UABoolean", subType: "Boolean" });
83
- registerBasicType({ name: "UtcTime", subType: "DateTime" });
84
- // already ? registerBasicType({name: "Int8", subType: "SByte"});
85
- // already ? registerBasicType({name: "UInt8", subType: "Byte"});
86
- registerBasicType({ name: "Char", subType: "Byte" });
87
- // xx registerBasicType({name:"XmlElement" ,subType:"String" });
88
- // xx registerBasicType({ name: "Time", subType: "String" });
89
- // string in the form "en-US" or "de-DE" or "fr" etc...
90
- registerBasicType({
91
- name: "LocaleId",
92
- subType: "String",
93
- defaultValue: null,
94
- decode: node_opcua_basic_types_1.decodeLocaleId,
95
- encode: node_opcua_basic_types_1.encodeLocaleId,
96
- validate: node_opcua_basic_types_1.validateLocaleId
97
- });
98
- registerBasicType({ name: "ContinuationPoint", subType: "ByteString" });
99
- registerBasicType({ name: "Image", subType: "ByteString" });
100
- registerBasicType({ name: "NodeIdType", subType: "NodeId" });
101
- registerBasicType({ name: "ImageBMP", subType: "Image" });
102
- registerBasicType({ name: "ImageGIF", subType: "Image" });
103
- registerBasicType({ name: "ImageJPG", subType: "Image" });
104
- registerBasicType({ name: "ImagePNG", subType: "Image" });
105
- registerBasicType({ name: "AudioDataType", subType: "ByteString" });
106
- registerBasicType({ name: "BitFieldMaskDataType", subType: "UInt64" });
107
- registerBasicType({ name: "DataSetFieldFlags", subType: "UInt16" });
108
- registerBasicType({ name: "DataSetFieldContentMask", subType: "UInt32" });
109
- registerBasicType({ name: "UadpNetworkMessageContentMask", subType: "UInt32" });
110
- registerBasicType({ name: "UadpDataSetMessageContentMask", subType: "UInt32" });
111
- registerBasicType({ name: "JsonNetworkMessageContentMask", subType: "UInt32" });
112
- registerBasicType({ name: "JsonDataSetMessageContentMask", subType: "UInt32" });
113
- registerBasicType({ name: "PermissionType", subType: "UInt32" });
114
- registerBasicType({ name: "AccessLevelType", subType: "Byte" });
115
- registerBasicType({ name: "AccessLevelExType", subType: "UInt32" });
116
- registerBasicType({ name: "EventNotifierType", subType: "Byte" });
117
- registerBasicType({ name: "AccessRestrictionType", subType: "UInt32" });
118
- registerBasicType({ name: "NormalizedString", subType: "String" });
119
- registerBasicType({ name: "DecimalString", subType: "String" });
120
- registerBasicType({ name: "DurationString", subType: "String" });
121
- registerBasicType({ name: "TimeString", subType: "String" });
122
- registerBasicType({ name: "DateString", subType: "String" });
123
- registerBasicType({ name: "Index", subType: "UInt32" });
124
- registerBasicType({ name: "VersionTime", subType: "UInt32" });
125
- registerBasicType({ name: "ApplicationInstanceCertificate", subType: "ByteString" });
126
- registerBasicType({ name: "AttributeWriteMask", subType: "UInt32" });
127
- registerBasicType({ name: "Date", subType: "DateTime" });
128
- // registerBasicType({ name: "Counter", subType: "UInt32" });
129
- // registerBasicType({ name: "IntegerId", subType: "UInt32" });
130
- // registerBasicType({ name: "UtcTime", subType: "DateTime" });
131
- // registerBasicType({ name: "Duration", subType: "Double" });
132
- // registerBasicType({ name: "LocaleId", subType: "String" });
133
- // registerBasicType({ name: "NumericRange", subType: "String" });
134
- // registerBasicType({ name: "Time", subType: "String" });
135
- // registerBasicType({ name: "SessionAuthenticationToken", subType: "NodeId" });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerBasicType = 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 factories_builtin_types_1 = require("./factories_builtin_types");
10
+ /**
11
+ * register a Basic Type ,
12
+ * A basic type is new entity type that resolved to a SubType
13
+ * @example:
14
+ *
15
+ *
16
+ * registerBasicType({name:"Duration" ,subType:"Double"});
17
+ *
18
+ * @method registerBasicType
19
+ * @param schema
20
+ * @param schema.name {String}
21
+ * @param schema.subType {String} mandatory, the basic type from which the new type derives.
22
+ *
23
+ * @param [schema.encode] {Function} optional,a specific encoder function to encode an instance of this type.
24
+ * @param schema.encode.value {*}
25
+ * @param schema.encode.stream {BinaryStream}
26
+ *
27
+ * @param [schema.decode] optional,a specific decoder function that returns the decode value out of the stream.
28
+ * @param [schema.decode.stream] {BinaryStream}
29
+ *
30
+ * @param [schema.coerce] optional, a method to convert a value into the request type.
31
+ * @param schema.coerce.value {*} the value to coerce.
32
+ *
33
+ * @param [schema.random] optional, a method to construct a random object of this type
34
+ *
35
+ * @param [schema.toJSON]optional, a method to convert a value into the request type.
36
+ */
37
+ function registerBasicType(schema) {
38
+ const exists = (0, factories_builtin_types_1.hasBuiltInType)(schema.name);
39
+ /* istanbul ignore next */
40
+ if (exists) {
41
+ // tslint:disable-next-line: no-console
42
+ console.log("registerBasicType:", schema);
43
+ throw new Error(`Basic Type ${schema.name} already registered`);
44
+ }
45
+ const name = schema.name;
46
+ const t = (0, factories_builtin_types_1.findSimpleType)(schema.subType);
47
+ /* istanbul ignore next */
48
+ if (!t) {
49
+ // tslint:disable-next-line:no-console
50
+ throw new Error(" cannot find subtype " + schema.subType);
51
+ }
52
+ (0, node_opcua_assert_1.assert)(typeof t.decode === "function");
53
+ const encodeFunc = schema.encode || t.encode;
54
+ (0, node_opcua_assert_1.assert)(typeof encodeFunc === "function");
55
+ const decodeFunc = schema.decode || t.decode;
56
+ (0, node_opcua_assert_1.assert)(typeof decodeFunc === "function");
57
+ const defaultValue = schema.defaultValue === undefined ? t.defaultValue : schema.defaultValue;
58
+ // assert(typeof defaultValue === "function");
59
+ const coerceFunc = schema.coerce || t.coerce;
60
+ const toJSONFunc = schema.toJSON || t.toJSON;
61
+ const random = schema.random || defaultValue;
62
+ const newSchema = {
63
+ name,
64
+ subType: schema.subType,
65
+ coerce: coerceFunc,
66
+ decode: decodeFunc,
67
+ encode: encodeFunc,
68
+ random,
69
+ defaultValue,
70
+ toJSON: toJSONFunc
71
+ };
72
+ (0, factories_builtin_types_1.registerType)(newSchema);
73
+ }
74
+ exports.registerBasicType = registerBasicType;
75
+ // =============================================================================================
76
+ // Registering the Basic Type already defined int the OPC-UA Specification
77
+ // =============================================================================================
78
+ registerBasicType({ name: "Counter", subType: "UInt32" });
79
+ // OPC Unified Architecture, part 3.0 $8.13 page 65
80
+ registerBasicType({ name: "Duration", subType: "Double" });
81
+ registerBasicType({ name: "UAString", subType: "String" });
82
+ registerBasicType({ name: "UABoolean", subType: "Boolean" });
83
+ registerBasicType({ name: "UtcTime", subType: "DateTime" });
84
+ // already ? registerBasicType({name: "Int8", subType: "SByte"});
85
+ // already ? registerBasicType({name: "UInt8", subType: "Byte"});
86
+ registerBasicType({ name: "Char", subType: "Byte" });
87
+ // xx registerBasicType({name:"XmlElement" ,subType:"String" });
88
+ // xx registerBasicType({ name: "Time", subType: "String" });
89
+ // string in the form "en-US" or "de-DE" or "fr" etc...
90
+ registerBasicType({
91
+ name: "LocaleId",
92
+ subType: "String",
93
+ defaultValue: null,
94
+ decode: node_opcua_basic_types_1.decodeLocaleId,
95
+ encode: node_opcua_basic_types_1.encodeLocaleId,
96
+ validate: node_opcua_basic_types_1.validateLocaleId
97
+ });
98
+ registerBasicType({ name: "ContinuationPoint", subType: "ByteString" });
99
+ registerBasicType({ name: "Image", subType: "ByteString" });
100
+ registerBasicType({ name: "NodeIdType", subType: "NodeId" });
101
+ registerBasicType({ name: "ImageBMP", subType: "Image" });
102
+ registerBasicType({ name: "ImageGIF", subType: "Image" });
103
+ registerBasicType({ name: "ImageJPG", subType: "Image" });
104
+ registerBasicType({ name: "ImagePNG", subType: "Image" });
105
+ registerBasicType({ name: "AudioDataType", subType: "ByteString" });
106
+ registerBasicType({ name: "BitFieldMaskDataType", subType: "UInt64" });
107
+ registerBasicType({ name: "DataSetFieldFlags", subType: "UInt16" });
108
+ registerBasicType({ name: "DataSetFieldContentMask", subType: "UInt32" });
109
+ registerBasicType({ name: "UadpNetworkMessageContentMask", subType: "UInt32" });
110
+ registerBasicType({ name: "UadpDataSetMessageContentMask", subType: "UInt32" });
111
+ registerBasicType({ name: "JsonNetworkMessageContentMask", subType: "UInt32" });
112
+ registerBasicType({ name: "JsonDataSetMessageContentMask", subType: "UInt32" });
113
+ registerBasicType({ name: "PermissionType", subType: "UInt32" });
114
+ registerBasicType({ name: "AccessLevelType", subType: "Byte" });
115
+ registerBasicType({ name: "AccessLevelExType", subType: "UInt32" });
116
+ registerBasicType({ name: "EventNotifierType", subType: "Byte" });
117
+ registerBasicType({ name: "AccessRestrictionType", subType: "UInt32" });
118
+ registerBasicType({ name: "NormalizedString", subType: "String" });
119
+ registerBasicType({ name: "DecimalString", subType: "String" });
120
+ registerBasicType({ name: "DurationString", subType: "String" });
121
+ registerBasicType({ name: "TimeString", subType: "String" });
122
+ registerBasicType({ name: "DateString", subType: "String" });
123
+ registerBasicType({ name: "Index", subType: "UInt32" });
124
+ registerBasicType({ name: "VersionTime", subType: "UInt32" });
125
+ registerBasicType({ name: "ApplicationInstanceCertificate", subType: "ByteString" });
126
+ registerBasicType({ name: "AttributeWriteMask", subType: "UInt32" });
127
+ registerBasicType({ name: "Date", subType: "DateTime" });
128
+ // registerBasicType({ name: "Counter", subType: "UInt32" });
129
+ // registerBasicType({ name: "IntegerId", subType: "UInt32" });
130
+ // registerBasicType({ name: "UtcTime", subType: "DateTime" });
131
+ // registerBasicType({ name: "Duration", subType: "Double" });
132
+ // registerBasicType({ name: "LocaleId", subType: "String" });
133
+ // registerBasicType({ name: "NumericRange", subType: "String" });
134
+ // registerBasicType({ name: "Time", subType: "String" });
135
+ // registerBasicType({ name: "SessionAuthenticationToken", subType: "NodeId" });
136
136
  //# sourceMappingURL=factories_basic_type.js.map
@@ -1,32 +1,32 @@
1
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
- import { BasicTypeDefinition, BasicTypeDefinitionOptions, TypeSchemaBase } from "./types";
3
- export declare class BasicTypeSchema extends TypeSchemaBase implements BasicTypeDefinition {
4
- subType: string;
5
- encode: (value: any, stream: OutputBinaryStream) => void;
6
- decode: (stream: BinaryStream) => any;
7
- constructor(options: BasicTypeDefinitionOptions);
8
- }
9
- export declare const minDate: Date;
10
- /**
11
- * @method registerType
12
- * @param schema {TypeSchemaBase}
13
- */
14
- export declare function registerType(schema: BasicTypeDefinitionOptions): void;
15
- export declare const registerBuiltInType: typeof registerType;
16
- export declare function unregisterType(typeName: string): void;
17
- /**
18
- * @method findSimpleType
19
- * @param name
20
- * @return {TypeSchemaBase|null}
21
- */
22
- export declare function findSimpleType(name: string): BasicTypeDefinition;
23
- export declare function hasBuiltInType(name: string): boolean;
24
- export declare function getBuildInType(name: string): BasicTypeDefinition;
25
- /**
26
- * @method findBuiltInType
27
- * find the Builtin Type that this
28
- * @param dataTypeName
29
- * @return {*}
30
- */
31
- export declare function findBuiltInType(dataTypeName: string): BasicTypeDefinition;
32
- export declare function getTypeMap(): Map<string, BasicTypeSchema>;
1
+ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
+ import { BasicTypeDefinition, BasicTypeDefinitionOptions, TypeSchemaBase } from "./types";
3
+ export declare class BasicTypeSchema extends TypeSchemaBase implements BasicTypeDefinition {
4
+ subType: string;
5
+ encode: (value: any, stream: OutputBinaryStream) => void;
6
+ decode: (stream: BinaryStream) => any;
7
+ constructor(options: BasicTypeDefinitionOptions);
8
+ }
9
+ export declare const minDate: Date;
10
+ /**
11
+ * @method registerType
12
+ * @param schema {TypeSchemaBase}
13
+ */
14
+ export declare function registerType(schema: BasicTypeDefinitionOptions): void;
15
+ export declare const registerBuiltInType: typeof registerType;
16
+ export declare function unregisterType(typeName: string): void;
17
+ /**
18
+ * @method findSimpleType
19
+ * @param name
20
+ * @return {TypeSchemaBase|null}
21
+ */
22
+ export declare function findSimpleType(name: string): BasicTypeDefinition;
23
+ export declare function hasBuiltInType(name: string): boolean;
24
+ export declare function getBuildInType(name: string): BasicTypeDefinition;
25
+ /**
26
+ * @method findBuiltInType
27
+ * find the Builtin Type that this
28
+ * @param dataTypeName
29
+ * @return {*}
30
+ */
31
+ export declare function findBuiltInType(dataTypeName: string): BasicTypeDefinition;
32
+ export declare function getTypeMap(): Map<string, BasicTypeSchema>;