@itwin/ecschema-metadata 4.0.0-dev.10 → 4.0.0-dev.100

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 (133) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/lib/cjs/Constants.d.ts +23 -23
  3. package/lib/cjs/Constants.js +33 -33
  4. package/lib/cjs/Constants.js.map +1 -1
  5. package/lib/cjs/Context.d.ts +139 -139
  6. package/lib/cjs/Context.js +204 -204
  7. package/lib/cjs/DelayedPromise.d.ts +88 -88
  8. package/lib/cjs/DelayedPromise.d.ts.map +1 -1
  9. package/lib/cjs/DelayedPromise.js +91 -91
  10. package/lib/cjs/DelayedPromise.js.map +1 -1
  11. package/lib/cjs/Deserialization/AbstractParser.d.ts +45 -45
  12. package/lib/cjs/Deserialization/AbstractParser.d.ts.map +1 -1
  13. package/lib/cjs/Deserialization/AbstractParser.js +11 -11
  14. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  15. package/lib/cjs/Deserialization/Helper.d.ts +251 -251
  16. package/lib/cjs/Deserialization/Helper.js +843 -843
  17. package/lib/cjs/Deserialization/JsonParser.d.ts +165 -165
  18. package/lib/cjs/Deserialization/JsonParser.d.ts.map +1 -1
  19. package/lib/cjs/Deserialization/JsonParser.js +680 -680
  20. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  21. package/lib/cjs/Deserialization/JsonProps.d.ts +268 -282
  22. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  23. package/lib/cjs/Deserialization/JsonProps.js +9 -9
  24. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  25. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +34 -34
  26. package/lib/cjs/Deserialization/SchemaGraphUtil.js +77 -77
  27. package/lib/cjs/Deserialization/XmlParser.d.ts +85 -85
  28. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  29. package/lib/cjs/Deserialization/XmlParser.js +973 -973
  30. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  31. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +54 -54
  32. package/lib/cjs/Deserialization/XmlSerializationUtils.js +174 -174
  33. package/lib/cjs/ECName.d.ts +30 -30
  34. package/lib/cjs/ECName.js +85 -85
  35. package/lib/cjs/ECObjects.d.ts +162 -162
  36. package/lib/cjs/ECObjects.js +453 -453
  37. package/lib/cjs/Exception.d.ts +43 -43
  38. package/lib/cjs/Exception.js +84 -84
  39. package/lib/cjs/Interfaces.d.ts +66 -66
  40. package/lib/cjs/Interfaces.d.ts.map +1 -1
  41. package/lib/cjs/Interfaces.js +9 -9
  42. package/lib/cjs/Metadata/Class.d.ts +243 -243
  43. package/lib/cjs/Metadata/Class.js +558 -558
  44. package/lib/cjs/Metadata/Class.js.map +1 -1
  45. package/lib/cjs/Metadata/Constant.d.ts +64 -64
  46. package/lib/cjs/Metadata/Constant.js +123 -123
  47. package/lib/cjs/Metadata/Constant.js.map +1 -1
  48. package/lib/cjs/Metadata/CustomAttribute.d.ts +23 -23
  49. package/lib/cjs/Metadata/CustomAttribute.js +27 -27
  50. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +39 -39
  51. package/lib/cjs/Metadata/CustomAttributeClass.js +68 -68
  52. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  53. package/lib/cjs/Metadata/EntityClass.d.ts +77 -77
  54. package/lib/cjs/Metadata/EntityClass.js +230 -230
  55. package/lib/cjs/Metadata/Enumeration.d.ts +86 -86
  56. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  57. package/lib/cjs/Metadata/Enumeration.js +159 -159
  58. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  59. package/lib/cjs/Metadata/Format.d.ts +98 -98
  60. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  61. package/lib/cjs/Metadata/Format.js +242 -242
  62. package/lib/cjs/Metadata/Format.js.map +1 -1
  63. package/lib/cjs/Metadata/InvertedUnit.d.ts +49 -49
  64. package/lib/cjs/Metadata/InvertedUnit.js +97 -97
  65. package/lib/cjs/Metadata/KindOfQuantity.d.ts +65 -65
  66. package/lib/cjs/Metadata/KindOfQuantity.js +225 -225
  67. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  68. package/lib/cjs/Metadata/Mixin.d.ts +54 -54
  69. package/lib/cjs/Metadata/Mixin.js +113 -113
  70. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  71. package/lib/cjs/Metadata/OverrideFormat.d.ts +67 -55
  72. package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
  73. package/lib/cjs/Metadata/OverrideFormat.js +126 -88
  74. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  75. package/lib/cjs/Metadata/Phenomenon.d.ts +33 -33
  76. package/lib/cjs/Metadata/Phenomenon.js +59 -59
  77. package/lib/cjs/Metadata/Property.d.ts +197 -197
  78. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  79. package/lib/cjs/Metadata/Property.js +491 -491
  80. package/lib/cjs/Metadata/Property.js.map +1 -1
  81. package/lib/cjs/Metadata/PropertyCategory.d.ts +39 -39
  82. package/lib/cjs/Metadata/PropertyCategory.js +61 -61
  83. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  84. package/lib/cjs/Metadata/RelationshipClass.d.ts +152 -152
  85. package/lib/cjs/Metadata/RelationshipClass.js +349 -349
  86. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  87. package/lib/cjs/Metadata/Schema.d.ts +291 -291
  88. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  89. package/lib/cjs/Metadata/Schema.js +520 -520
  90. package/lib/cjs/Metadata/Schema.js.map +1 -1
  91. package/lib/cjs/Metadata/SchemaItem.d.ts +61 -61
  92. package/lib/cjs/Metadata/SchemaItem.js +136 -136
  93. package/lib/cjs/Metadata/Unit.d.ts +76 -76
  94. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  95. package/lib/cjs/Metadata/Unit.js +162 -162
  96. package/lib/cjs/Metadata/Unit.js.map +1 -1
  97. package/lib/cjs/Metadata/UnitSystem.d.ts +20 -20
  98. package/lib/cjs/Metadata/UnitSystem.js +29 -29
  99. package/lib/cjs/PropertyTypes.d.ts +49 -49
  100. package/lib/cjs/PropertyTypes.js +91 -91
  101. package/lib/cjs/PropertyTypes.js.map +1 -1
  102. package/lib/cjs/SchemaJsonLocater.d.ts +34 -34
  103. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  104. package/lib/cjs/SchemaJsonLocater.js +42 -42
  105. package/lib/cjs/SchemaKey.d.ts +110 -110
  106. package/lib/cjs/SchemaKey.js +219 -219
  107. package/lib/cjs/SchemaLoader.d.ts +23 -23
  108. package/lib/cjs/SchemaLoader.js +47 -47
  109. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +274 -274
  110. package/lib/cjs/SchemaPartVisitorDelegate.js +212 -212
  111. package/lib/cjs/UnitConversion/Graph.d.ts +34 -34
  112. package/lib/cjs/UnitConversion/Graph.js +83 -83
  113. package/lib/cjs/UnitConversion/Parser.d.ts +8 -8
  114. package/lib/cjs/UnitConversion/Parser.js +42 -42
  115. package/lib/cjs/UnitConversion/UnitConversion.d.ts +45 -45
  116. package/lib/cjs/UnitConversion/UnitConversion.js +77 -77
  117. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  118. package/lib/cjs/UnitConversion/UnitConverter.d.ts +39 -39
  119. package/lib/cjs/UnitConversion/UnitConverter.js +116 -116
  120. package/lib/cjs/UnitConversion/UnitTree.d.ts +43 -43
  121. package/lib/cjs/UnitConversion/UnitTree.js +169 -169
  122. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +77 -77
  123. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  124. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +234 -236
  125. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  126. package/lib/cjs/Validation/SchemaWalker.d.ts +23 -23
  127. package/lib/cjs/Validation/SchemaWalker.js +53 -53
  128. package/lib/cjs/ecschema-metadata.d.ts +51 -51
  129. package/lib/cjs/ecschema-metadata.js +100 -96
  130. package/lib/cjs/ecschema-metadata.js.map +1 -1
  131. package/lib/cjs/utils/SchemaGraph.d.ts +25 -25
  132. package/lib/cjs/utils/SchemaGraph.js +65 -65
  133. package/package.json +13 -14
@@ -1,117 +1,117 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnitConverter = void 0;
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
8
- const core_bentley_1 = require("@itwin/core-bentley");
9
- const SchemaItem_1 = require("../Metadata/SchemaItem");
10
- const Unit_1 = require("../Metadata/Unit");
11
- const SchemaKey_1 = require("../SchemaKey");
12
- const UnitConversion_1 = require("./UnitConversion");
13
- const UnitTree_1 = require("./UnitTree");
14
- /**
15
- * Class constructed with SchemaContext and used to calculate [[UnitConversion]] between Units
16
- * @internal
17
- */
18
- class UnitConverter {
19
- /**
20
- * Create Converter context
21
- * @param _context SchemaContext with contexts added to it.
22
- */
23
- constructor(_context) {
24
- this._context = _context;
25
- this._uGraph = new UnitTree_1.UnitGraph(this._context);
26
- }
27
- /**
28
- * Find conversion between from and to units, formatted {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}
29
- * @param fromUnit SchemaItem full name of source unit
30
- * @param toUnit SchemaItem full name of target unit
31
- * @returns [[UnitConversion]] converting fromUnit -> toUnit with a factor and an offset
32
- * @throws Error if from and to Units' SchemaItem is not found in Schema or Schema prefix is not found in SchemaContext
33
- * @throws Error if from and to Units do not belong to the same phenomenon
34
- * @throws Error if definitions' SchemaItems cannot be found in its own or referenced Schemas
35
- * @throws Error if base units of source and target unit do not match
36
- */
37
- async calculateConversion(fromUnit, toUnit) {
38
- const [fromSchemaName, fromSchemaItemName] = SchemaItem_1.SchemaItem.parseFullName(fromUnit);
39
- const [toSchemaName, toSchemaItemName] = SchemaItem_1.SchemaItem.parseFullName(toUnit);
40
- const fromSchemaKey = new SchemaKey_1.SchemaKey(fromSchemaName);
41
- const toSchemaKey = new SchemaKey_1.SchemaKey(toSchemaName);
42
- const fromSchema = await this._context.getSchema(fromSchemaKey);
43
- const toSchema = await this._context.getSchema(toSchemaKey);
44
- if (!fromSchema || !toSchema) {
45
- throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Cannot find from's and/or to's schema", () => {
46
- return { from: fromUnit, fromSchema: fromSchemaName, to: toUnit, toSchema: toSchemaName };
47
- });
48
- }
49
- const from = await this._uGraph.resolveUnit(fromSchemaItemName, fromSchema);
50
- const to = await this._uGraph.resolveUnit(toSchemaItemName, toSchema);
51
- return this.processUnits(from, to);
52
- }
53
- /**
54
- * @param from Source unit converted from
55
- * @param to Target unit converted to
56
- * @internal
57
- */
58
- async processUnits(from, to) {
59
- if (from.key.matches(to.key))
60
- return UnitConversion_1.UnitConversion.identity;
61
- const areCompatible = await Unit_1.Unit.areCompatible(from, to);
62
- if (!areCompatible)
63
- throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, `Source and target units do not belong to same phenomenon`, () => {
64
- return { from, to };
65
- });
66
- // Add nodes and subsequent children to graph
67
- await this._uGraph.addUnit(from);
68
- await this._uGraph.addUnit(to);
69
- const fromBaseUnits = new Map();
70
- const toBaseUnits = new Map();
71
- // Calculate map of UnitConversions to get between from -> base
72
- const fromMapStore = this._uGraph.reduce(from, fromBaseUnits);
73
- // Calculate map of UnitConversions to get between base -> to
74
- const toMapStore = this._uGraph.reduce(to, toBaseUnits);
75
- if (!this.checkBaseUnitsMatch(fromBaseUnits, toBaseUnits))
76
- throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, `Source and target units do not have matching base units`, () => {
77
- return { from, to };
78
- });
79
- // Final calculations to get singular UnitConversion between from -> to
80
- const fromMap = fromMapStore.get(from.key.fullName) || UnitConversion_1.UnitConversion.identity;
81
- const toMap = toMapStore.get(to.key.fullName) || UnitConversion_1.UnitConversion.identity;
82
- const fromInverse = fromMap.inverse();
83
- return fromInverse.compose(toMap);
84
- }
85
- /**
86
- * Check if fromBaseUnits's base units and exponents matches toBaseUnits's
87
- * @param fromBaseUnits Map of base units for source unit
88
- * @param toBaseUnits Map of base units for target unit
89
- * @internal
90
- */
91
- checkBaseUnitsMatch(fromBaseUnits, toBaseUnits) {
92
- // Trim maps of "One" and value that equal zero as they do not affect the base units and calculations
93
- for (const [key, value] of fromBaseUnits.entries()) {
94
- const [, schemaItemName] = SchemaItem_1.SchemaItem.parseFullName(key);
95
- if (schemaItemName === "ONE" || value === 0) {
96
- fromBaseUnits.delete(key);
97
- }
98
- }
99
- for (const [key, value] of toBaseUnits.entries()) {
100
- const [, schemaItemName] = SchemaItem_1.SchemaItem.parseFullName(key);
101
- if (schemaItemName === "ONE" || value === 0) {
102
- toBaseUnits.delete(key);
103
- }
104
- }
105
- if (fromBaseUnits.size !== toBaseUnits.size)
106
- return false;
107
- for (const key of fromBaseUnits.keys()) {
108
- if (!toBaseUnits.has(key) || fromBaseUnits.get(key) !== toBaseUnits.get(key)) {
109
- // Mismatching key or value
110
- return false;
111
- }
112
- }
113
- return true;
114
- }
115
- }
116
- exports.UnitConverter = UnitConverter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnitConverter = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ const core_bentley_1 = require("@itwin/core-bentley");
9
+ const SchemaItem_1 = require("../Metadata/SchemaItem");
10
+ const Unit_1 = require("../Metadata/Unit");
11
+ const SchemaKey_1 = require("../SchemaKey");
12
+ const UnitConversion_1 = require("./UnitConversion");
13
+ const UnitTree_1 = require("./UnitTree");
14
+ /**
15
+ * Class constructed with SchemaContext and used to calculate [[UnitConversion]] between Units
16
+ * @internal
17
+ */
18
+ class UnitConverter {
19
+ /**
20
+ * Create Converter context
21
+ * @param _context SchemaContext with contexts added to it.
22
+ */
23
+ constructor(_context) {
24
+ this._context = _context;
25
+ this._uGraph = new UnitTree_1.UnitGraph(this._context);
26
+ }
27
+ /**
28
+ * Find conversion between from and to units, formatted {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}
29
+ * @param fromUnit SchemaItem full name of source unit
30
+ * @param toUnit SchemaItem full name of target unit
31
+ * @returns [[UnitConversion]] converting fromUnit -> toUnit with a factor and an offset
32
+ * @throws Error if from and to Units' SchemaItem is not found in Schema or Schema prefix is not found in SchemaContext
33
+ * @throws Error if from and to Units do not belong to the same phenomenon
34
+ * @throws Error if definitions' SchemaItems cannot be found in its own or referenced Schemas
35
+ * @throws Error if base units of source and target unit do not match
36
+ */
37
+ async calculateConversion(fromUnit, toUnit) {
38
+ const [fromSchemaName, fromSchemaItemName] = SchemaItem_1.SchemaItem.parseFullName(fromUnit);
39
+ const [toSchemaName, toSchemaItemName] = SchemaItem_1.SchemaItem.parseFullName(toUnit);
40
+ const fromSchemaKey = new SchemaKey_1.SchemaKey(fromSchemaName);
41
+ const toSchemaKey = new SchemaKey_1.SchemaKey(toSchemaName);
42
+ const fromSchema = await this._context.getSchema(fromSchemaKey);
43
+ const toSchema = await this._context.getSchema(toSchemaKey);
44
+ if (!fromSchema || !toSchema) {
45
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Cannot find from's and/or to's schema", () => {
46
+ return { from: fromUnit, fromSchema: fromSchemaName, to: toUnit, toSchema: toSchemaName };
47
+ });
48
+ }
49
+ const from = await this._uGraph.resolveUnit(fromSchemaItemName, fromSchema);
50
+ const to = await this._uGraph.resolveUnit(toSchemaItemName, toSchema);
51
+ return this.processUnits(from, to);
52
+ }
53
+ /**
54
+ * @param from Source unit converted from
55
+ * @param to Target unit converted to
56
+ * @internal
57
+ */
58
+ async processUnits(from, to) {
59
+ if (from.key.matches(to.key))
60
+ return UnitConversion_1.UnitConversion.identity;
61
+ const areCompatible = await Unit_1.Unit.areCompatible(from, to);
62
+ if (!areCompatible)
63
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, `Source and target units do not belong to same phenomenon`, () => {
64
+ return { from, to };
65
+ });
66
+ // Add nodes and subsequent children to graph
67
+ await this._uGraph.addUnit(from);
68
+ await this._uGraph.addUnit(to);
69
+ const fromBaseUnits = new Map();
70
+ const toBaseUnits = new Map();
71
+ // Calculate map of UnitConversions to get between from -> base
72
+ const fromMapStore = this._uGraph.reduce(from, fromBaseUnits);
73
+ // Calculate map of UnitConversions to get between base -> to
74
+ const toMapStore = this._uGraph.reduce(to, toBaseUnits);
75
+ if (!this.checkBaseUnitsMatch(fromBaseUnits, toBaseUnits))
76
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, `Source and target units do not have matching base units`, () => {
77
+ return { from, to };
78
+ });
79
+ // Final calculations to get singular UnitConversion between from -> to
80
+ const fromMap = fromMapStore.get(from.key.fullName) || UnitConversion_1.UnitConversion.identity;
81
+ const toMap = toMapStore.get(to.key.fullName) || UnitConversion_1.UnitConversion.identity;
82
+ const fromInverse = fromMap.inverse();
83
+ return fromInverse.compose(toMap);
84
+ }
85
+ /**
86
+ * Check if fromBaseUnits's base units and exponents matches toBaseUnits's
87
+ * @param fromBaseUnits Map of base units for source unit
88
+ * @param toBaseUnits Map of base units for target unit
89
+ * @internal
90
+ */
91
+ checkBaseUnitsMatch(fromBaseUnits, toBaseUnits) {
92
+ // Trim maps of "One" and value that equal zero as they do not affect the base units and calculations
93
+ for (const [key, value] of fromBaseUnits.entries()) {
94
+ const [, schemaItemName] = SchemaItem_1.SchemaItem.parseFullName(key);
95
+ if (schemaItemName === "ONE" || value === 0) {
96
+ fromBaseUnits.delete(key);
97
+ }
98
+ }
99
+ for (const [key, value] of toBaseUnits.entries()) {
100
+ const [, schemaItemName] = SchemaItem_1.SchemaItem.parseFullName(key);
101
+ if (schemaItemName === "ONE" || value === 0) {
102
+ toBaseUnits.delete(key);
103
+ }
104
+ }
105
+ if (fromBaseUnits.size !== toBaseUnits.size)
106
+ return false;
107
+ for (const key of fromBaseUnits.keys()) {
108
+ if (!toBaseUnits.has(key) || fromBaseUnits.get(key) !== toBaseUnits.get(key)) {
109
+ // Mismatching key or value
110
+ return false;
111
+ }
112
+ }
113
+ return true;
114
+ }
115
+ }
116
+ exports.UnitConverter = UnitConverter;
117
117
  //# sourceMappingURL=UnitConverter.js.map
@@ -1,44 +1,44 @@
1
- import { SchemaContext } from "../Context";
2
- import { Constant } from "../Metadata/Constant";
3
- import { Schema } from "../Metadata/Schema";
4
- import { Unit } from "../Metadata/Unit";
5
- import { UnitConversion } from "./UnitConversion";
6
- import { Graph } from "./Graph";
7
- /** @internal */
8
- export declare class GraphUtils {
9
- /**
10
- * DFS traversal - Post order
11
- * @param _graph Graph to traverse
12
- * @param start Starting node
13
- * @param keyFrom Get key from label
14
- * @param op Reducing function
15
- * @param initial Initial label
16
- */
17
- static dfsReduce<T>(_graph: Graph<Unit | Constant>, key: string, op: (previous: T, current: string) => T, initial: T, baseUnitsMap: Map<string, number>, accumulatedExponent: number): T;
18
- }
19
- /** @internal */
20
- export declare class UnitGraph {
21
- private _context;
22
- private _graph;
23
- constructor(_context: SchemaContext);
24
- /**
25
- * Tries to find the unit/constant given by name in currentSchema
26
- * @param name SchemaItem name or parsed definition to find unit of; Could be {schemaName}:{schemaItemName} or {alias}:{schemaItemName} or {schemaItemName}
27
- * @param currentSchema schema to find name in; name could also be in a referenced schema of current schema
28
- */
29
- resolveUnit(name: string, currentSchema: Schema): Promise<Unit | Constant>;
30
- /**
31
- * Adds unit and corresponding children to graph as well as edges between units
32
- * @param unit Current unit to be added to graph
33
- */
34
- addUnit(unit: Unit | Constant): Promise<void>;
35
- private isIdentity;
36
- /**
37
- * Reduce the tree to produce a single map
38
- * @param unit Unit to be processed
39
- * @param stopNodes The tree exploration should stop here
40
- */
41
- reduce(unit: Unit | Constant, baseUnitsMap: Map<string, number>): Map<string, UnitConversion>;
42
- private reducingFunction;
43
- }
1
+ import { SchemaContext } from "../Context";
2
+ import { Constant } from "../Metadata/Constant";
3
+ import { Schema } from "../Metadata/Schema";
4
+ import { Unit } from "../Metadata/Unit";
5
+ import { UnitConversion } from "./UnitConversion";
6
+ import { Graph } from "./Graph";
7
+ /** @internal */
8
+ export declare class GraphUtils {
9
+ /**
10
+ * DFS traversal - Post order
11
+ * @param _graph Graph to traverse
12
+ * @param start Starting node
13
+ * @param keyFrom Get key from label
14
+ * @param op Reducing function
15
+ * @param initial Initial label
16
+ */
17
+ static dfsReduce<T>(_graph: Graph<Unit | Constant>, key: string, op: (previous: T, current: string) => T, initial: T, baseUnitsMap: Map<string, number>, accumulatedExponent: number): T;
18
+ }
19
+ /** @internal */
20
+ export declare class UnitGraph {
21
+ private _context;
22
+ private _graph;
23
+ constructor(_context: SchemaContext);
24
+ /**
25
+ * Tries to find the unit/constant given by name in currentSchema
26
+ * @param name SchemaItem name or parsed definition to find unit of; Could be {schemaName}:{schemaItemName} or {alias}:{schemaItemName} or {schemaItemName}
27
+ * @param currentSchema schema to find name in; name could also be in a referenced schema of current schema
28
+ */
29
+ resolveUnit(name: string, currentSchema: Schema): Promise<Unit | Constant>;
30
+ /**
31
+ * Adds unit and corresponding children to graph as well as edges between units
32
+ * @param unit Current unit to be added to graph
33
+ */
34
+ addUnit(unit: Unit | Constant): Promise<void>;
35
+ private isIdentity;
36
+ /**
37
+ * Reduce the tree to produce a single map
38
+ * @param unit Unit to be processed
39
+ * @param stopNodes The tree exploration should stop here
40
+ */
41
+ reduce(unit: Unit | Constant, baseUnitsMap: Map<string, number>): Map<string, UnitConversion>;
42
+ private reducingFunction;
43
+ }
44
44
  //# sourceMappingURL=UnitTree.d.ts.map