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,31 +1,31 @@
1
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
- import { Enum, EnumItem, _TypescriptEnum } from "node-opcua-enum";
3
- import { EnumerationDefinition, TypeSchemaBase, TypeSchemaConstructorOptions } from "./types";
4
- export interface EnumerationDefinitionOptions extends TypeSchemaConstructorOptions {
5
- enumValues: _TypescriptEnum | string[];
6
- typedEnum?: Enum;
7
- lengthInBits?: number;
8
- defaultValue?: EnumItem;
9
- encode?: (value: EnumItem, stream: OutputBinaryStream) => void;
10
- decode?: (stream: BinaryStream) => EnumItem;
11
- }
12
- export declare class EnumerationDefinitionSchema extends TypeSchemaBase implements EnumerationDefinition {
13
- enumValues: _TypescriptEnum;
14
- typedEnum: Enum;
15
- lengthInBits: number;
16
- constructor(options: EnumerationDefinitionOptions);
17
- }
18
- /**
19
- * @method registerEnumeration
20
- * @param options
21
- * @param options.name {string}
22
- * @param options.enumValues [{key:Name, value:values}]
23
- * @param options.encode
24
- * @param options.decode
25
- * @param options.typedEnum
26
- * @param options.defaultValue
27
- * @return {Enum}
28
- */
29
- export declare function registerEnumeration(options: EnumerationDefinitionOptions): Enum;
30
- export declare function hasEnumeration(enumerationName: string): boolean;
31
- export declare function getEnumeration(enumerationName: string): EnumerationDefinitionSchema;
1
+ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
+ import { Enum, EnumItem, _TypescriptEnum } from "node-opcua-enum";
3
+ import { EnumerationDefinition, TypeSchemaBase, TypeSchemaConstructorOptions } from "./types";
4
+ export interface EnumerationDefinitionOptions extends TypeSchemaConstructorOptions {
5
+ enumValues: _TypescriptEnum | string[];
6
+ typedEnum?: Enum;
7
+ lengthInBits?: number;
8
+ defaultValue?: EnumItem;
9
+ encode?: (value: EnumItem, stream: OutputBinaryStream) => void;
10
+ decode?: (stream: BinaryStream) => EnumItem;
11
+ }
12
+ export declare class EnumerationDefinitionSchema extends TypeSchemaBase implements EnumerationDefinition {
13
+ enumValues: _TypescriptEnum;
14
+ typedEnum: Enum;
15
+ lengthInBits: number;
16
+ constructor(options: EnumerationDefinitionOptions);
17
+ }
18
+ /**
19
+ * @method registerEnumeration
20
+ * @param options
21
+ * @param options.name {string}
22
+ * @param options.enumValues [{key:Name, value:values}]
23
+ * @param options.encode
24
+ * @param options.decode
25
+ * @param options.typedEnum
26
+ * @param options.defaultValue
27
+ * @return {Enum}
28
+ */
29
+ export declare function registerEnumeration(options: EnumerationDefinitionOptions): Enum;
30
+ export declare function hasEnumeration(enumerationName: string): boolean;
31
+ export declare function getEnumeration(enumerationName: string): EnumerationDefinitionSchema;
@@ -1,78 +1,78 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEnumeration = exports.hasEnumeration = exports.registerEnumeration = exports.EnumerationDefinitionSchema = void 0;
4
- /**
5
- * @module node-opcua-factory
6
- */
7
- const node_opcua_assert_1 = require("node-opcua-assert");
8
- const node_opcua_enum_1 = require("node-opcua-enum");
9
- const types_1 = require("./types");
10
- function _encode_enumeration(typedEnum, value, stream) {
11
- (0, node_opcua_assert_1.assert)(typeof value === "number", "Expecting a number here");
12
- (0, node_opcua_assert_1.assert)(typedEnum.get(value) !== undefined, "expecting a valid value");
13
- stream.writeInteger(value);
14
- }
15
- function _decode_enumeration(typedEnum, stream) {
16
- const value = stream.readInteger();
17
- const e = typedEnum.get(value);
18
- // istanbul ignore next
19
- if (!e) {
20
- throw new Error("cannot coerce value=" + value + " to " + typedEnum.constructor.name);
21
- }
22
- return value;
23
- }
24
- class EnumerationDefinitionSchema extends types_1.TypeSchemaBase {
25
- // xx encode: (value: EnumItem, stream: OutputBinaryStream) => void;
26
- // xx decode: (stream: BinaryStream) => EnumItem;
27
- constructor(options) {
28
- super(options);
29
- // create a new Enum
30
- this.enumValues = (0, node_opcua_enum_1.adaptTypescriptEnum)(options.enumValues);
31
- const typedEnum = new node_opcua_enum_1.Enum(options.enumValues);
32
- options.typedEnum = typedEnum;
33
- (0, node_opcua_assert_1.assert)(!options.encode || typeof options.encode === "function");
34
- (0, node_opcua_assert_1.assert)(!options.decode || typeof options.decode === "function");
35
- this.encode = options.encode || _encode_enumeration.bind(null, typedEnum);
36
- this.decode = options.decode || _decode_enumeration.bind(null, typedEnum);
37
- this.typedEnum = options.typedEnum;
38
- this.defaultValue = this.typedEnum.getDefaultValue().value;
39
- this.lengthInBits = options.lengthInBits || 32;
40
- }
41
- }
42
- exports.EnumerationDefinitionSchema = EnumerationDefinitionSchema;
43
- const _enumerations = new Map();
44
- /**
45
- * @method registerEnumeration
46
- * @param options
47
- * @param options.name {string}
48
- * @param options.enumValues [{key:Name, value:values}]
49
- * @param options.encode
50
- * @param options.decode
51
- * @param options.typedEnum
52
- * @param options.defaultValue
53
- * @return {Enum}
54
- */
55
- function registerEnumeration(options) {
56
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "name"));
57
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "enumValues"));
58
- const name = options.name;
59
- if (Object.prototype.hasOwnProperty.call(_enumerations, name)) {
60
- throw new Error("factories.registerEnumeration : Enumeration " + options.name + " has been already inserted");
61
- }
62
- const enumerationDefinition = new EnumerationDefinitionSchema(options);
63
- _enumerations.set(name, enumerationDefinition);
64
- return enumerationDefinition.typedEnum;
65
- }
66
- exports.registerEnumeration = registerEnumeration;
67
- function hasEnumeration(enumerationName) {
68
- return _enumerations.has(enumerationName);
69
- }
70
- exports.hasEnumeration = hasEnumeration;
71
- function getEnumeration(enumerationName) {
72
- if (!exports.hasEnumeration(enumerationName)) {
73
- throw new Error("Cannot find enumeration with type " + enumerationName);
74
- }
75
- return _enumerations.get(enumerationName);
76
- }
77
- exports.getEnumeration = getEnumeration;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnumeration = exports.hasEnumeration = exports.registerEnumeration = exports.EnumerationDefinitionSchema = void 0;
4
+ /**
5
+ * @module node-opcua-factory
6
+ */
7
+ const node_opcua_assert_1 = require("node-opcua-assert");
8
+ const node_opcua_enum_1 = require("node-opcua-enum");
9
+ const types_1 = require("./types");
10
+ function _encode_enumeration(typedEnum, value, stream) {
11
+ (0, node_opcua_assert_1.assert)(typeof value === "number", "Expecting a number here");
12
+ (0, node_opcua_assert_1.assert)(typedEnum.get(value) !== undefined, "expecting a valid value");
13
+ stream.writeInteger(value);
14
+ }
15
+ function _decode_enumeration(typedEnum, stream) {
16
+ const value = stream.readInteger();
17
+ const e = typedEnum.get(value);
18
+ // istanbul ignore next
19
+ if (!e) {
20
+ throw new Error("cannot coerce value=" + value + " to " + typedEnum.constructor.name);
21
+ }
22
+ return value;
23
+ }
24
+ class EnumerationDefinitionSchema extends types_1.TypeSchemaBase {
25
+ // xx encode: (value: EnumItem, stream: OutputBinaryStream) => void;
26
+ // xx decode: (stream: BinaryStream) => EnumItem;
27
+ constructor(options) {
28
+ super(options);
29
+ // create a new Enum
30
+ this.enumValues = (0, node_opcua_enum_1.adaptTypescriptEnum)(options.enumValues);
31
+ const typedEnum = new node_opcua_enum_1.Enum(options.enumValues);
32
+ options.typedEnum = typedEnum;
33
+ (0, node_opcua_assert_1.assert)(!options.encode || typeof options.encode === "function");
34
+ (0, node_opcua_assert_1.assert)(!options.decode || typeof options.decode === "function");
35
+ this.encode = options.encode || _encode_enumeration.bind(null, typedEnum);
36
+ this.decode = options.decode || _decode_enumeration.bind(null, typedEnum);
37
+ this.typedEnum = options.typedEnum;
38
+ this.defaultValue = this.typedEnum.getDefaultValue().value;
39
+ this.lengthInBits = options.lengthInBits || 32;
40
+ }
41
+ }
42
+ exports.EnumerationDefinitionSchema = EnumerationDefinitionSchema;
43
+ const _enumerations = new Map();
44
+ /**
45
+ * @method registerEnumeration
46
+ * @param options
47
+ * @param options.name {string}
48
+ * @param options.enumValues [{key:Name, value:values}]
49
+ * @param options.encode
50
+ * @param options.decode
51
+ * @param options.typedEnum
52
+ * @param options.defaultValue
53
+ * @return {Enum}
54
+ */
55
+ function registerEnumeration(options) {
56
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "name"));
57
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "enumValues"));
58
+ const name = options.name;
59
+ if (Object.prototype.hasOwnProperty.call(_enumerations, name)) {
60
+ throw new Error("factories.registerEnumeration : Enumeration " + options.name + " has been already inserted");
61
+ }
62
+ const enumerationDefinition = new EnumerationDefinitionSchema(options);
63
+ _enumerations.set(name, enumerationDefinition);
64
+ return enumerationDefinition.typedEnum;
65
+ }
66
+ exports.registerEnumeration = registerEnumeration;
67
+ function hasEnumeration(enumerationName) {
68
+ return _enumerations.has(enumerationName);
69
+ }
70
+ exports.hasEnumeration = hasEnumeration;
71
+ function getEnumeration(enumerationName) {
72
+ if (!exports.hasEnumeration(enumerationName)) {
73
+ throw new Error("Cannot find enumeration with type " + enumerationName);
74
+ }
75
+ return _enumerations.get(enumerationName);
76
+ }
77
+ exports.getEnumeration = getEnumeration;
78
78
  //# sourceMappingURL=factories_enumerations.js.map
@@ -1,17 +1,17 @@
1
- /**
2
- * @module node-opcua-factory
3
- */
4
- import { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
5
- import { DataTypeFactory } from "./datatype_factory";
6
- import { ConstructorFuncWithSchema, ConstructorFunc } from "./constructor_type";
7
- import { BaseUAObject } from "./factories_baseobject";
8
- import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
9
- export declare function getStandardDataTypeFactory(): DataTypeFactory;
10
- export declare function getStructureTypeConstructor(typeName: string): ConstructorFuncWithSchema;
11
- export declare function hasStructuredType(typeName: string): boolean;
12
- export declare function getStructuredTypeSchema(typeName: string): StructuredTypeSchema;
13
- export declare function getConstructor(binaryEncodingNodeId: ExpandedNodeId): ConstructorFunc | null;
14
- export declare function hasConstructor(binaryEncodingNodeId: ExpandedNodeId): boolean;
15
- export declare function constructObject(binaryEncodingNodeId: ExpandedNodeId): BaseUAObject;
16
- export declare function registerClassDefinition(dataTypeNodeId: NodeId, className: string, classConstructor: ConstructorFuncWithSchema): void;
17
- export declare function dump(): void;
1
+ /**
2
+ * @module node-opcua-factory
3
+ */
4
+ import { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
5
+ import { DataTypeFactory } from "./datatype_factory";
6
+ import { ConstructorFuncWithSchema, ConstructorFunc } from "./constructor_type";
7
+ import { BaseUAObject } from "./factories_baseobject";
8
+ import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
9
+ export declare function getStandardDataTypeFactory(): DataTypeFactory;
10
+ export declare function getStructureTypeConstructor(typeName: string): ConstructorFuncWithSchema;
11
+ export declare function hasStructuredType(typeName: string): boolean;
12
+ export declare function getStructuredTypeSchema(typeName: string): StructuredTypeSchema;
13
+ export declare function getConstructor(binaryEncodingNodeId: ExpandedNodeId): ConstructorFunc | null;
14
+ export declare function hasConstructor(binaryEncodingNodeId: ExpandedNodeId): boolean;
15
+ export declare function constructObject(binaryEncodingNodeId: ExpandedNodeId): BaseUAObject;
16
+ export declare function registerClassDefinition(dataTypeNodeId: NodeId, className: string, classConstructor: ConstructorFuncWithSchema): void;
17
+ export declare function dump(): void;
@@ -1,54 +1,54 @@
1
- "use strict";
2
- /**
3
- * @module node-opcua-factory
4
- */
5
- // tslint:disable:no-console
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.dump = exports.registerClassDefinition = exports.constructObject = exports.hasConstructor = exports.getConstructor = exports.getStructuredTypeSchema = exports.hasStructuredType = exports.getStructureTypeConstructor = exports.getStandardDataTypeFactory = void 0;
8
- const node_opcua_debug_1 = require("node-opcua-debug");
9
- const datatype_factory_1 = require("./datatype_factory");
10
- const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
11
- const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
12
- let globalFactory;
13
- function getStandardDataTypeFactory() {
14
- if (!globalFactory) {
15
- globalFactory = new datatype_factory_1.DataTypeFactory([]);
16
- globalFactory.targetNamespace = "http://opcfoundation.org/UA/";
17
- }
18
- return globalFactory;
19
- }
20
- exports.getStandardDataTypeFactory = getStandardDataTypeFactory;
21
- function getStructureTypeConstructor(typeName) {
22
- return getStandardDataTypeFactory().getStructureTypeConstructor(typeName);
23
- }
24
- exports.getStructureTypeConstructor = getStructureTypeConstructor;
25
- function hasStructuredType(typeName) {
26
- return getStandardDataTypeFactory().hasStructuredType(typeName);
27
- }
28
- exports.hasStructuredType = hasStructuredType;
29
- function getStructuredTypeSchema(typeName) {
30
- return getStandardDataTypeFactory().getStructuredTypeSchema(typeName);
31
- }
32
- exports.getStructuredTypeSchema = getStructuredTypeSchema;
33
- function getConstructor(binaryEncodingNodeId) {
34
- return getStandardDataTypeFactory().getConstructor(binaryEncodingNodeId);
35
- }
36
- exports.getConstructor = getConstructor;
37
- function hasConstructor(binaryEncodingNodeId) {
38
- return getStandardDataTypeFactory().hasConstructor(binaryEncodingNodeId);
39
- }
40
- exports.hasConstructor = hasConstructor;
41
- function constructObject(binaryEncodingNodeId) {
42
- return getStandardDataTypeFactory().constructObject(binaryEncodingNodeId);
43
- }
44
- exports.constructObject = constructObject;
45
- function registerClassDefinition(dataTypeNodeId, className, classConstructor) {
46
- return getStandardDataTypeFactory().registerClassDefinition(dataTypeNodeId, className, classConstructor);
47
- }
48
- exports.registerClassDefinition = registerClassDefinition;
49
- /* istanbul ignore next */
50
- function dump() {
51
- getStandardDataTypeFactory().dump();
52
- }
53
- exports.dump = dump;
1
+ "use strict";
2
+ /**
3
+ * @module node-opcua-factory
4
+ */
5
+ // tslint:disable:no-console
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.dump = exports.registerClassDefinition = exports.constructObject = exports.hasConstructor = exports.getConstructor = exports.getStructuredTypeSchema = exports.hasStructuredType = exports.getStructureTypeConstructor = exports.getStandardDataTypeFactory = void 0;
8
+ const node_opcua_debug_1 = require("node-opcua-debug");
9
+ const datatype_factory_1 = require("./datatype_factory");
10
+ const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
11
+ const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
12
+ let globalFactory;
13
+ function getStandardDataTypeFactory() {
14
+ if (!globalFactory) {
15
+ globalFactory = new datatype_factory_1.DataTypeFactory([]);
16
+ globalFactory.targetNamespace = "http://opcfoundation.org/UA/";
17
+ }
18
+ return globalFactory;
19
+ }
20
+ exports.getStandardDataTypeFactory = getStandardDataTypeFactory;
21
+ function getStructureTypeConstructor(typeName) {
22
+ return getStandardDataTypeFactory().getStructureTypeConstructor(typeName);
23
+ }
24
+ exports.getStructureTypeConstructor = getStructureTypeConstructor;
25
+ function hasStructuredType(typeName) {
26
+ return getStandardDataTypeFactory().hasStructuredType(typeName);
27
+ }
28
+ exports.hasStructuredType = hasStructuredType;
29
+ function getStructuredTypeSchema(typeName) {
30
+ return getStandardDataTypeFactory().getStructuredTypeSchema(typeName);
31
+ }
32
+ exports.getStructuredTypeSchema = getStructuredTypeSchema;
33
+ function getConstructor(binaryEncodingNodeId) {
34
+ return getStandardDataTypeFactory().getConstructor(binaryEncodingNodeId);
35
+ }
36
+ exports.getConstructor = getConstructor;
37
+ function hasConstructor(binaryEncodingNodeId) {
38
+ return getStandardDataTypeFactory().hasConstructor(binaryEncodingNodeId);
39
+ }
40
+ exports.hasConstructor = hasConstructor;
41
+ function constructObject(binaryEncodingNodeId) {
42
+ return getStandardDataTypeFactory().constructObject(binaryEncodingNodeId);
43
+ }
44
+ exports.constructObject = constructObject;
45
+ function registerClassDefinition(dataTypeNodeId, className, classConstructor) {
46
+ return getStandardDataTypeFactory().registerClassDefinition(dataTypeNodeId, className, classConstructor);
47
+ }
48
+ exports.registerClassDefinition = registerClassDefinition;
49
+ /* istanbul ignore next */
50
+ function dump() {
51
+ getStandardDataTypeFactory().dump();
52
+ }
53
+ exports.dump = dump;
54
54
  //# sourceMappingURL=factories_factories.js.map
@@ -1,3 +1,3 @@
1
- export declare function generate_new_id(): number;
2
- export declare function next_available_id(): number;
3
- export declare function is_internal_id(value: number): boolean;
1
+ export declare function generate_new_id(): number;
2
+ export declare function next_available_id(): number;
3
+ export declare function is_internal_id(value: number): boolean;
@@ -1,22 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.is_internal_id = exports.next_available_id = exports.generate_new_id = void 0;
4
- /**
5
- * @module node-opcua-factory
6
- */
7
- const _FIRST_INTERNAL_ID = 0xfffe0000;
8
- let _nextAvailableId = _FIRST_INTERNAL_ID;
9
- function generate_new_id() {
10
- _nextAvailableId += 1;
11
- return _nextAvailableId;
12
- }
13
- exports.generate_new_id = generate_new_id;
14
- function next_available_id() {
15
- return -1;
16
- }
17
- exports.next_available_id = next_available_id;
18
- function is_internal_id(value) {
19
- return value >= _FIRST_INTERNAL_ID;
20
- }
21
- exports.is_internal_id = is_internal_id;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.is_internal_id = exports.next_available_id = exports.generate_new_id = void 0;
4
+ /**
5
+ * @module node-opcua-factory
6
+ */
7
+ const _FIRST_INTERNAL_ID = 0xfffe0000;
8
+ let _nextAvailableId = _FIRST_INTERNAL_ID;
9
+ function generate_new_id() {
10
+ _nextAvailableId += 1;
11
+ return _nextAvailableId;
12
+ }
13
+ exports.generate_new_id = generate_new_id;
14
+ function next_available_id() {
15
+ return -1;
16
+ }
17
+ exports.next_available_id = next_available_id;
18
+ function is_internal_id(value) {
19
+ return value >= _FIRST_INTERNAL_ID;
20
+ }
21
+ exports.is_internal_id = is_internal_id;
22
22
  //# sourceMappingURL=factories_id_generator.js.map
@@ -1,27 +1,27 @@
1
- import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
2
- import { FieldType, StructuredTypeField } from "./types";
3
- export declare const parameters: {
4
- debugSchemaHelper: boolean;
5
- };
6
- /**
7
- * ensure correctness of a schema object.
8
- *
9
- * @method check_schema_correctness
10
- * @param schema
11
- *
12
- */
13
- export declare function check_schema_correctness(schema: StructuredTypeSchema): void;
14
- /**
15
- * @method initialize_value
16
- * @param value
17
- * @param defaultValue
18
- * @return {*}
19
- */
20
- export declare function initialize_field(field: StructuredTypeField, value: unknown): any;
21
- /**
22
- * @method initialize_field_array
23
- * @param field
24
- * @param valueArray
25
- * @return
26
- */
27
- export declare function initialize_field_array(field: FieldType, valueArray: any): any;
1
+ import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
2
+ import { FieldType, StructuredTypeField } from "./types";
3
+ export declare const parameters: {
4
+ debugSchemaHelper: boolean;
5
+ };
6
+ /**
7
+ * ensure correctness of a schema object.
8
+ *
9
+ * @method check_schema_correctness
10
+ * @param schema
11
+ *
12
+ */
13
+ export declare function check_schema_correctness(schema: StructuredTypeSchema): void;
14
+ /**
15
+ * @method initialize_value
16
+ * @param value
17
+ * @param defaultValue
18
+ * @return {*}
19
+ */
20
+ export declare function initialize_field(field: StructuredTypeField, value: unknown): any;
21
+ /**
22
+ * @method initialize_field_array
23
+ * @param field
24
+ * @param valueArray
25
+ * @return
26
+ */
27
+ export declare function initialize_field_array(field: FieldType, valueArray: any): any;