node-opcua-factory 2.78.0 → 2.81.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 (31) hide show
  1. package/package.json +5 -5
  2. package/dist/constructor_type.d.ts +0 -15
  3. package/dist/constructor_type.js +0 -3
  4. package/dist/constructor_type.js.map +0 -1
  5. package/dist/factories_baseobject.d.ts +0 -56
  6. package/dist/factories_baseobject.js +0 -535
  7. package/dist/factories_baseobject.js.map +0 -1
  8. package/dist/factories_basic_type.d.ts +0 -40
  9. package/dist/factories_basic_type.js +0 -136
  10. package/dist/factories_basic_type.js.map +0 -1
  11. package/dist/factories_builtin_types.d.ts +0 -32
  12. package/dist/factories_builtin_types.js +0 -262
  13. package/dist/factories_builtin_types.js.map +0 -1
  14. package/dist/factories_builtin_types_special.d.ts +0 -5
  15. package/dist/factories_builtin_types_special.js +0 -46
  16. package/dist/factories_builtin_types_special.js.map +0 -1
  17. package/dist/factories_enumerations.d.ts +0 -31
  18. package/dist/factories_enumerations.js +0 -78
  19. package/dist/factories_enumerations.js.map +0 -1
  20. package/dist/factories_factories.d.ts +0 -17
  21. package/dist/factories_factories.js +0 -54
  22. package/dist/factories_factories.js.map +0 -1
  23. package/dist/factories_id_generator.d.ts +0 -3
  24. package/dist/factories_id_generator.js +0 -22
  25. package/dist/factories_id_generator.js.map +0 -1
  26. package/dist/factories_schema_helpers.d.ts +0 -27
  27. package/dist/factories_schema_helpers.js +0 -122
  28. package/dist/factories_schema_helpers.js.map +0 -1
  29. package/dist/factories_structuredTypeSchema.d.ts +0 -45
  30. package/dist/factories_structuredTypeSchema.js +0 -277
  31. package/dist/factories_structuredTypeSchema.js.map +0 -1
@@ -1,78 +0,0 @@
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
- //# sourceMappingURL=factories_enumerations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factories_enumerations.js","sourceRoot":"","sources":["../source/factories_enumerations.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAG3C,qDAAuF;AACvF,mCAA8F;AAE9F,SAAS,mBAAmB,CAAC,SAAe,EAAE,KAAa,EAAE,MAA0B;IACnF,IAAA,0BAAM,EAAC,OAAO,KAAK,KAAK,QAAQ,EAAE,yBAAyB,CAAC,CAAC;IAC7D,IAAA,0BAAM,EAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,SAAS,EAAE,yBAAyB,CAAC,CAAC;IACtE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAe,EAAE,MAAoB;IAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACnC,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAkB,CAAC;IAChD,uBAAuB;IACvB,IAAI,CAAC,CAAC,EAAE;QACJ,MAAM,IAAI,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B,CAAC,OAAqC;IACrE,IAAA,0BAAM,EAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9D,IAAA,0BAAM,EAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,8CAA8C,GAAG,OAAO,CAAC,IAAI,GAAG,4BAA4B,CAAC,CAAC;KACjH;IACD,MAAM,qBAAqB,GAAG,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACvE,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;IAE/C,OAAO,qBAAqB,CAAC,SAAS,CAAC;AAC3C,CAAC;AAZD,kDAYC;AAED,SAAgB,cAAc,CAAC,eAAuB;IAClD,OAAO,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAC9C,CAAC;AAFD,wCAEC;AAED,SAAgB,cAAc,CAAC,eAAuB;IAClD,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE;QAC1C,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,eAAe,CAAC,CAAC;KAC3E;IACD,OAAO,aAAa,CAAC,GAAG,CAAC,eAAe,CAAgC,CAAC;AAC7E,CAAC;AALD,wCAKC"}
@@ -1,17 +0,0 @@
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 +0,0 @@
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
- //# sourceMappingURL=factories_factories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factories_factories.js","sourceRoot":"","sources":["../source/factories_factories.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,4BAA4B;;;AAK5B,uDAAiE;AAGjE,yDAAqD;AAMrD,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,UAAU,CAAC,CAAC;AAE3C,IAAI,aAA8B,CAAC;AACnC,SAAgB,0BAA0B;IACtC,IAAI,CAAC,aAAa,EAAE;QAChB,aAAa,GAAG,IAAI,kCAAe,CAAC,EAAE,CAAC,CAAC;QACxC,aAAa,CAAC,eAAe,GAAG,8BAA8B,CAAC;KAClE;IACD,OAAO,aAAa,CAAC;AACzB,CAAC;AAND,gEAMC;AACD,SAAgB,2BAA2B,CAAC,QAAgB;IACxD,OAAO,0BAA0B,EAAE,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;AAC9E,CAAC;AAFD,kEAEC;AACD,SAAgB,iBAAiB,CAAC,QAAgB;IAC9C,OAAO,0BAA0B,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AACpE,CAAC;AAFD,8CAEC;AACD,SAAgB,uBAAuB,CAAC,QAAgB;IACpD,OAAO,0BAA0B,EAAE,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;AAC1E,CAAC;AAFD,0DAEC;AAED,SAAgB,cAAc,CAAC,oBAAoC;IAC/D,OAAO,0BAA0B,EAAE,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;AAC7E,CAAC;AAFD,wCAEC;AACD,SAAgB,cAAc,CAAC,oBAAoC;IAC/D,OAAO,0BAA0B,EAAE,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;AAC7E,CAAC;AAFD,wCAEC;AACD,SAAgB,eAAe,CAAC,oBAAoC;IAChE,OAAO,0BAA0B,EAAE,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAC9E,CAAC;AAFD,0CAEC;AACD,SAAgB,uBAAuB,CACnC,cAAsB,EACtB,SAAiB,EACjB,gBAA2C;IAE3C,OAAO,0BAA0B,EAAE,CAAC,uBAAuB,CAAC,cAAc,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAC7G,CAAC;AAND,0DAMC;AACD,0BAA0B;AAC1B,SAAgB,IAAI;IAChB,0BAA0B,EAAE,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC;AAFD,oBAEC"}
@@ -1,3 +0,0 @@
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 +0,0 @@
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
- //# sourceMappingURL=factories_id_generator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factories_id_generator.js","sourceRoot":"","sources":["../source/factories_id_generator.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAEtC,IAAI,gBAAgB,GAAG,kBAAkB,CAAC;AAE1C,SAAgB,eAAe;IAC3B,gBAAgB,IAAI,CAAC,CAAC;IACtB,OAAO,gBAAgB,CAAC;AAC5B,CAAC;AAHD,0CAGC;AAED,SAAgB,iBAAiB;IAC7B,OAAO,CAAC,CAAC,CAAC;AACd,CAAC;AAFD,8CAEC;AACD,SAAgB,cAAc,CAAC,KAAa;IACxC,OAAO,KAAK,IAAI,kBAAkB,CAAC;AACvC,CAAC;AAFD,wCAEC"}
@@ -1,27 +0,0 @@
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,122 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initialize_field_array = exports.initialize_field = exports.check_schema_correctness = exports.parameters = void 0;
4
- /**
5
- * @module node-opcua-factory
6
- */
7
- const node_opcua_assert_1 = require("node-opcua-assert");
8
- const node_opcua_debug_1 = require("node-opcua-debug");
9
- const types_1 = require("./types");
10
- const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
11
- exports.parameters = {
12
- debugSchemaHelper: (typeof process === "object" && !!process.env.DEBUG_CLASS)
13
- };
14
- /**
15
- * ensure correctness of a schema object.
16
- *
17
- * @method check_schema_correctness
18
- * @param schema
19
- *
20
- */
21
- function check_schema_correctness(schema) {
22
- (0, node_opcua_assert_1.assert)(typeof schema.name === "string", " expecting schema to have a name");
23
- (0, node_opcua_assert_1.assert)(schema.fields instanceof Array, " expecting schema to provide a set of fields " + schema.name);
24
- (0, node_opcua_assert_1.assert)(schema.baseType === undefined || typeof schema.baseType === "string");
25
- }
26
- exports.check_schema_correctness = check_schema_correctness;
27
- /**
28
- * @method initialize_value
29
- * @param value
30
- * @param defaultValue
31
- * @return {*}
32
- */
33
- function initialize_field(field, value) {
34
- const _t = field.schema;
35
- if (!(_t !== null && typeof _t === "object")) {
36
- throw new Error("initialize_field: expecting field.schema to be set field.name = '" + field.name + "' type = " + field.fieldType);
37
- }
38
- if (field.category === types_1.FieldCategory.complex) {
39
- if (field.fieldTypeConstructor) {
40
- return new field.fieldTypeConstructor(value);
41
- }
42
- else {
43
- debugLog("xxxx => missing constructor for field type", field.fieldType);
44
- }
45
- }
46
- if (value === undefined || value === null) {
47
- const defaultValue = _t.computer_default_value ? _t.computer_default_value(field.defaultValue) : field.defaultValue;
48
- if (value === undefined) {
49
- if (_t.coerce) {
50
- return _t.coerce(defaultValue);
51
- }
52
- return defaultValue;
53
- }
54
- if (defaultValue === null) {
55
- if (value === null) {
56
- return null;
57
- }
58
- }
59
- }
60
- if (_t.coerce) {
61
- value = _t.coerce(value);
62
- }
63
- if (field.validate) {
64
- if (!field.validate(value)) {
65
- throw Error(" invalid value " + value + " for field " + field.name + " of type " + field.fieldType);
66
- }
67
- }
68
- return value;
69
- }
70
- exports.initialize_field = initialize_field;
71
- function initialize_value(value, defaultValue, _t) {
72
- if (value === undefined) {
73
- return defaultValue;
74
- }
75
- if (defaultValue === null) {
76
- if (value === null) {
77
- return null;
78
- }
79
- }
80
- if (_t.coerce) {
81
- value = _t.coerce(value);
82
- return value;
83
- }
84
- return value;
85
- }
86
- /**
87
- * @method initialize_field_array
88
- * @param field
89
- * @param valueArray
90
- * @return
91
- */
92
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
93
- function initialize_field_array(field, valueArray) {
94
- const _t = field.schema;
95
- let value;
96
- let i;
97
- (0, node_opcua_assert_1.assert)(field !== null && typeof field === "object");
98
- (0, node_opcua_assert_1.assert)(field.isArray);
99
- if (!valueArray && field.defaultValue === null) {
100
- return null;
101
- }
102
- valueArray = valueArray || [];
103
- let defaultValue;
104
- if (_t.computer_default_value) {
105
- defaultValue = _t.computer_default_value(field.defaultValue);
106
- }
107
- const arr = [];
108
- for (i = 0; i < valueArray.length; i++) {
109
- value = initialize_value(valueArray[i], defaultValue, _t);
110
- arr.push(value);
111
- }
112
- if (field.validate) {
113
- for (i = 0; i < arr.length; i++) {
114
- if (!field.validate(arr[i])) {
115
- throw Error(" invalid value " + arr[i] + " for field " + field.name + " of type " + field.fieldType);
116
- }
117
- }
118
- }
119
- return arr;
120
- }
121
- exports.initialize_field_array = initialize_field_array;
122
- //# sourceMappingURL=factories_schema_helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factories_schema_helpers.js","sourceRoot":"","sources":["../source/factories_schema_helpers.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAC3C,uDAAiD;AAEjD,mCAAyF;AAEzF,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAE9B,QAAA,UAAU,GAAG;IACtB,iBAAiB,EAAE,CAAC,OAAO,OAAO,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eFactory } from "./datatype_factory";
4
- import { FieldType, StructuredTypeOptions, TypeSchemaBase } from "./types";
5
- export declare class StructuredTypeSchema extends TypeSchemaBase {
6
- fields: FieldType[];
7
- id: NodeId;
8
- dataTypeNodeId: NodeId;
9
- baseType: string;
10
- _possibleFields: string[];
11
- _baseSchema: StructuredTypeSchema | null;
12
- documentation?: string;
13
- isValid?: (options: any) => boolean;
14
- decodeDebug?: (stream: BinaryStream, options: any) => any;
15
- constructHook?: (options: any) => any;
16
- encodingDefaultBinary?: ExpandedNodeId;
17
- encodingDefaultXml?: ExpandedNodeId;
18
- encodingDefaultJson?: ExpandedNodeId;
19
- bitFields?: any[];
20
- constructor(options: StructuredTypeOptions);
21
- toString(): string;
22
- }
23
- /**
24
- *
25
- * @method get_base_schema
26
- * @param schema
27
- * @return {*}
28
- *
29
- */
30
- export declare function get_base_schema(schema: StructuredTypeSchema): StructuredTypeSchema | null;
31
- /**
32
- * extract a list of all possible fields for a schema
33
- * (by walking up the inheritance chain)
34
- *
35
- */
36
- export declare function extract_all_fields(schema: StructuredTypeSchema): string[];
37
- /**
38
- * check correctness of option fields against scheme
39
- *
40
- * @method check_options_correctness_against_schema
41
- *
42
- */
43
- export declare function check_options_correctness_against_schema(obj: any, schema: StructuredTypeSchema, options: any): boolean;
44
- export declare function buildStructuredType2(dataTypeFactory: DataTypeFactory, schemaLight: StructuredTypeOptions): StructuredTypeSchema;
45
- export declare function buildStructuredType(schemaLight: StructuredTypeOptions): StructuredTypeSchema;