@itwin/ecschema-metadata 4.0.0-dev.7 → 4.0.0-dev.72

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 (121) hide show
  1. package/CHANGELOG.md +41 -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/Helper.d.ts +251 -251
  15. package/lib/cjs/Deserialization/Helper.js +843 -843
  16. package/lib/cjs/Deserialization/JsonParser.d.ts +165 -165
  17. package/lib/cjs/Deserialization/JsonParser.js +680 -680
  18. package/lib/cjs/Deserialization/JsonProps.d.ts +282 -282
  19. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  20. package/lib/cjs/Deserialization/JsonProps.js +9 -9
  21. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +34 -34
  22. package/lib/cjs/Deserialization/SchemaGraphUtil.js +77 -77
  23. package/lib/cjs/Deserialization/XmlParser.d.ts +85 -85
  24. package/lib/cjs/Deserialization/XmlParser.js +973 -973
  25. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +54 -54
  26. package/lib/cjs/Deserialization/XmlSerializationUtils.js +174 -174
  27. package/lib/cjs/ECName.d.ts +30 -30
  28. package/lib/cjs/ECName.js +85 -85
  29. package/lib/cjs/ECObjects.d.ts +162 -162
  30. package/lib/cjs/ECObjects.js +453 -453
  31. package/lib/cjs/Exception.d.ts +43 -43
  32. package/lib/cjs/Exception.js +84 -84
  33. package/lib/cjs/Interfaces.d.ts +66 -66
  34. package/lib/cjs/Interfaces.d.ts.map +1 -1
  35. package/lib/cjs/Interfaces.js +9 -9
  36. package/lib/cjs/Metadata/Class.d.ts +243 -243
  37. package/lib/cjs/Metadata/Class.js +558 -558
  38. package/lib/cjs/Metadata/Class.js.map +1 -1
  39. package/lib/cjs/Metadata/Constant.d.ts +64 -64
  40. package/lib/cjs/Metadata/Constant.js +123 -123
  41. package/lib/cjs/Metadata/Constant.js.map +1 -1
  42. package/lib/cjs/Metadata/CustomAttribute.d.ts +23 -23
  43. package/lib/cjs/Metadata/CustomAttribute.js +27 -27
  44. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +39 -39
  45. package/lib/cjs/Metadata/CustomAttributeClass.js +68 -68
  46. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  47. package/lib/cjs/Metadata/EntityClass.d.ts +77 -77
  48. package/lib/cjs/Metadata/EntityClass.js +230 -230
  49. package/lib/cjs/Metadata/Enumeration.d.ts +86 -86
  50. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  51. package/lib/cjs/Metadata/Enumeration.js +159 -159
  52. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  53. package/lib/cjs/Metadata/Format.d.ts +98 -98
  54. package/lib/cjs/Metadata/Format.js +242 -242
  55. package/lib/cjs/Metadata/InvertedUnit.d.ts +49 -49
  56. package/lib/cjs/Metadata/InvertedUnit.js +97 -97
  57. package/lib/cjs/Metadata/KindOfQuantity.d.ts +65 -65
  58. package/lib/cjs/Metadata/KindOfQuantity.js +225 -225
  59. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  60. package/lib/cjs/Metadata/Mixin.d.ts +54 -54
  61. package/lib/cjs/Metadata/Mixin.js +113 -113
  62. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  63. package/lib/cjs/Metadata/OverrideFormat.d.ts +55 -55
  64. package/lib/cjs/Metadata/OverrideFormat.js +88 -88
  65. package/lib/cjs/Metadata/Phenomenon.d.ts +33 -33
  66. package/lib/cjs/Metadata/Phenomenon.js +59 -59
  67. package/lib/cjs/Metadata/Property.d.ts +197 -197
  68. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  69. package/lib/cjs/Metadata/Property.js +491 -491
  70. package/lib/cjs/Metadata/Property.js.map +1 -1
  71. package/lib/cjs/Metadata/PropertyCategory.d.ts +39 -39
  72. package/lib/cjs/Metadata/PropertyCategory.js +61 -61
  73. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  74. package/lib/cjs/Metadata/RelationshipClass.d.ts +152 -152
  75. package/lib/cjs/Metadata/RelationshipClass.js +349 -349
  76. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  77. package/lib/cjs/Metadata/Schema.d.ts +291 -291
  78. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  79. package/lib/cjs/Metadata/Schema.js +520 -520
  80. package/lib/cjs/Metadata/Schema.js.map +1 -1
  81. package/lib/cjs/Metadata/SchemaItem.d.ts +61 -61
  82. package/lib/cjs/Metadata/SchemaItem.js +136 -136
  83. package/lib/cjs/Metadata/Unit.d.ts +76 -76
  84. package/lib/cjs/Metadata/Unit.js +162 -162
  85. package/lib/cjs/Metadata/Unit.js.map +1 -1
  86. package/lib/cjs/Metadata/UnitSystem.d.ts +20 -20
  87. package/lib/cjs/Metadata/UnitSystem.js +29 -29
  88. package/lib/cjs/PropertyTypes.d.ts +49 -49
  89. package/lib/cjs/PropertyTypes.js +91 -91
  90. package/lib/cjs/PropertyTypes.js.map +1 -1
  91. package/lib/cjs/SchemaJsonLocater.d.ts +34 -34
  92. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  93. package/lib/cjs/SchemaJsonLocater.js +42 -42
  94. package/lib/cjs/SchemaKey.d.ts +110 -110
  95. package/lib/cjs/SchemaKey.js +219 -219
  96. package/lib/cjs/SchemaLoader.d.ts +23 -23
  97. package/lib/cjs/SchemaLoader.js +47 -47
  98. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +274 -274
  99. package/lib/cjs/SchemaPartVisitorDelegate.js +212 -212
  100. package/lib/cjs/UnitConversion/Graph.d.ts +34 -34
  101. package/lib/cjs/UnitConversion/Graph.js +83 -83
  102. package/lib/cjs/UnitConversion/Parser.d.ts +8 -8
  103. package/lib/cjs/UnitConversion/Parser.js +42 -42
  104. package/lib/cjs/UnitConversion/UnitConversion.d.ts +45 -45
  105. package/lib/cjs/UnitConversion/UnitConversion.js +77 -77
  106. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  107. package/lib/cjs/UnitConversion/UnitConverter.d.ts +39 -39
  108. package/lib/cjs/UnitConversion/UnitConverter.js +116 -116
  109. package/lib/cjs/UnitConversion/UnitTree.d.ts +43 -43
  110. package/lib/cjs/UnitConversion/UnitTree.js +169 -169
  111. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +77 -77
  112. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +234 -236
  113. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  114. package/lib/cjs/Validation/SchemaWalker.d.ts +23 -23
  115. package/lib/cjs/Validation/SchemaWalker.js +53 -53
  116. package/lib/cjs/ecschema-metadata.d.ts +51 -51
  117. package/lib/cjs/ecschema-metadata.js +100 -96
  118. package/lib/cjs/ecschema-metadata.js.map +1 -1
  119. package/lib/cjs/utils/SchemaGraph.d.ts +25 -25
  120. package/lib/cjs/utils/SchemaGraph.js +65 -65
  121. package/package.json +12 -12
@@ -1,170 +1,170 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnitGraph = exports.GraphUtils = 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 SchemaKey_1 = require("../SchemaKey");
11
- const ECObjects_1 = require("../ECObjects");
12
- const UnitConversion_1 = require("./UnitConversion");
13
- const Parser_1 = require("./Parser");
14
- const Graph_1 = require("./Graph");
15
- /** @internal */
16
- class GraphUtils {
17
- /**
18
- * DFS traversal - Post order
19
- * @param _graph Graph to traverse
20
- * @param start Starting node
21
- * @param keyFrom Get key from label
22
- * @param op Reducing function
23
- * @param initial Initial label
24
- */
25
- static dfsReduce(_graph, key, op, initial, baseUnitsMap, accumulatedExponent) {
26
- const outEdges = _graph.outEdges(key);
27
- let t = initial;
28
- if (outEdges.length > 0) {
29
- t = outEdges.reduce((p, edge) => {
30
- const { v, w } = edge;
31
- const edgeExponent = _graph.edge(v, w).exponent;
32
- return GraphUtils.dfsReduce(_graph, edge.w, op, p, baseUnitsMap, accumulatedExponent * edgeExponent);
33
- }, t);
34
- }
35
- else {
36
- if (baseUnitsMap.has(key)) {
37
- const oldExponent = baseUnitsMap.get(key);
38
- baseUnitsMap.set(key, oldExponent + accumulatedExponent);
39
- }
40
- else {
41
- baseUnitsMap.set(key, accumulatedExponent);
42
- }
43
- }
44
- return op(t, key);
45
- }
46
- }
47
- exports.GraphUtils = GraphUtils;
48
- /** @internal */
49
- class UnitGraph {
50
- constructor(_context) {
51
- this._context = _context;
52
- this._graph = new Graph_1.Graph();
53
- this._graph.setGraph("Unit tree processor");
54
- }
55
- /**
56
- * Tries to find the unit/constant given by name in currentSchema
57
- * @param name SchemaItem name or parsed definition to find unit of; Could be {schemaName}:{schemaItemName} or {alias}:{schemaItemName} or {schemaItemName}
58
- * @param currentSchema schema to find name in; name could also be in a referenced schema of current schema
59
- */
60
- async resolveUnit(name, currentSchema) {
61
- let [schemaName] = SchemaItem_1.SchemaItem.parseFullName(name);
62
- const [, schemaItemName] = SchemaItem_1.SchemaItem.parseFullName(name);
63
- if (schemaName !== "") {
64
- // Check if schemaName is schemaName or alias
65
- const ref = currentSchema.getReferenceSync(schemaName);
66
- const refName = currentSchema.getReferenceNameByAlias(schemaName);
67
- if (ref) {
68
- // Got schema by schemaName
69
- schemaName = ref.name;
70
- }
71
- else if (refName) {
72
- // Got schema by alias
73
- schemaName = refName;
74
- }
75
- else {
76
- // Didn't match any referenced schema, check if it is current schemaName or alias
77
- if (schemaName === currentSchema.name || schemaName === currentSchema.alias)
78
- schemaName = currentSchema.name;
79
- }
80
- // Create schema key with schema name
81
- const schemaKey = new SchemaKey_1.SchemaKey(schemaName);
82
- // Get schema with schema key
83
- const schema = await this._context.getSchema(schemaKey);
84
- if (!schema) {
85
- throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Cannot find schema", () => {
86
- return { schema: schemaName };
87
- });
88
- }
89
- else {
90
- // Set currentSchema to look up schemaItem to be whatever is prefixed in name
91
- currentSchema = schema;
92
- }
93
- // Update name to not have prefix
94
- name = schemaItemName;
95
- }
96
- // Create schema item key with name and schema
97
- const itemKey = new SchemaKey_1.SchemaItemKey(name, currentSchema.schemaKey);
98
- // Get schema item with schema item key
99
- const item = await this._context.getSchemaItem(itemKey);
100
- if (!item)
101
- throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Cannot find schema item", () => {
102
- return { item: name };
103
- });
104
- if (item.schemaItemType === ECObjects_1.SchemaItemType.Unit || item.schemaItemType === ECObjects_1.SchemaItemType.Constant)
105
- return item;
106
- throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Item is neither a unit or a constant", () => {
107
- return { itemType: item.key.fullName };
108
- });
109
- }
110
- /**
111
- * Adds unit and corresponding children to graph as well as edges between units
112
- * @param unit Current unit to be added to graph
113
- */
114
- async addUnit(unit) {
115
- if (this._graph.hasNode(unit.key.fullName))
116
- return;
117
- this._graph.setNode(unit.key.fullName, unit);
118
- if (this.isIdentity(unit))
119
- return;
120
- const umap = (0, Parser_1.parseDefinition)(unit.definition);
121
- const promiseArray = [];
122
- for (const [key, value] of umap) {
123
- promiseArray.push(this.resolveUnit(key, unit.schema).then((u) => [u, value]));
124
- }
125
- const resolved = await Promise.all(promiseArray);
126
- const children = resolved.map(async ([u, def]) => {
127
- await this.addUnit(u);
128
- this._graph.setEdge(unit.key.fullName, u.key.fullName, {
129
- exponent: def.exponent,
130
- });
131
- });
132
- await Promise.all(children);
133
- }
134
- isIdentity(unit) {
135
- return unit.definition === unit.name;
136
- }
137
- /**
138
- * Reduce the tree to produce a single map
139
- * @param unit Unit to be processed
140
- * @param stopNodes The tree exploration should stop here
141
- */
142
- reduce(unit, baseUnitsMap) {
143
- const unitFullName = unit.key.fullName;
144
- const innerMapStore = new Map();
145
- const outerMapStore = GraphUtils.dfsReduce(this._graph, unitFullName, (p, c) => this.reducingFunction(p, c), innerMapStore, baseUnitsMap, 1);
146
- return outerMapStore;
147
- }
148
- reducingFunction(innermapStore, unitFullName) {
149
- const outEdges = this._graph.outEdges(unitFullName);
150
- if (outEdges) {
151
- const cmap = outEdges.reduce((pm, e) => {
152
- const { exponent } = this._graph.edge(e.v, e.w);
153
- const stored = innermapStore.get(e.w);
154
- const map = stored ? stored : UnitConversion_1.UnitConversion.identity;
155
- const emap = map.raise(exponent);
156
- return pm ? pm.multiply(emap) : emap;
157
- }, undefined);
158
- const thisMap = this._graph.node(unitFullName) ? UnitConversion_1.UnitConversion.from(this._graph.node(unitFullName)) : UnitConversion_1.UnitConversion.identity;
159
- const other = cmap || UnitConversion_1.UnitConversion.identity;
160
- const result = other.compose(thisMap);
161
- innermapStore.set(unitFullName, result);
162
- }
163
- else {
164
- innermapStore.set(unitFullName, UnitConversion_1.UnitConversion.identity);
165
- }
166
- return innermapStore;
167
- }
168
- }
169
- exports.UnitGraph = UnitGraph;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnitGraph = exports.GraphUtils = 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 SchemaKey_1 = require("../SchemaKey");
11
+ const ECObjects_1 = require("../ECObjects");
12
+ const UnitConversion_1 = require("./UnitConversion");
13
+ const Parser_1 = require("./Parser");
14
+ const Graph_1 = require("./Graph");
15
+ /** @internal */
16
+ class GraphUtils {
17
+ /**
18
+ * DFS traversal - Post order
19
+ * @param _graph Graph to traverse
20
+ * @param start Starting node
21
+ * @param keyFrom Get key from label
22
+ * @param op Reducing function
23
+ * @param initial Initial label
24
+ */
25
+ static dfsReduce(_graph, key, op, initial, baseUnitsMap, accumulatedExponent) {
26
+ const outEdges = _graph.outEdges(key);
27
+ let t = initial;
28
+ if (outEdges.length > 0) {
29
+ t = outEdges.reduce((p, edge) => {
30
+ const { v, w } = edge;
31
+ const edgeExponent = _graph.edge(v, w).exponent;
32
+ return GraphUtils.dfsReduce(_graph, edge.w, op, p, baseUnitsMap, accumulatedExponent * edgeExponent);
33
+ }, t);
34
+ }
35
+ else {
36
+ if (baseUnitsMap.has(key)) {
37
+ const oldExponent = baseUnitsMap.get(key);
38
+ baseUnitsMap.set(key, oldExponent + accumulatedExponent);
39
+ }
40
+ else {
41
+ baseUnitsMap.set(key, accumulatedExponent);
42
+ }
43
+ }
44
+ return op(t, key);
45
+ }
46
+ }
47
+ exports.GraphUtils = GraphUtils;
48
+ /** @internal */
49
+ class UnitGraph {
50
+ constructor(_context) {
51
+ this._context = _context;
52
+ this._graph = new Graph_1.Graph();
53
+ this._graph.setGraph("Unit tree processor");
54
+ }
55
+ /**
56
+ * Tries to find the unit/constant given by name in currentSchema
57
+ * @param name SchemaItem name or parsed definition to find unit of; Could be {schemaName}:{schemaItemName} or {alias}:{schemaItemName} or {schemaItemName}
58
+ * @param currentSchema schema to find name in; name could also be in a referenced schema of current schema
59
+ */
60
+ async resolveUnit(name, currentSchema) {
61
+ let [schemaName] = SchemaItem_1.SchemaItem.parseFullName(name);
62
+ const [, schemaItemName] = SchemaItem_1.SchemaItem.parseFullName(name);
63
+ if (schemaName !== "") {
64
+ // Check if schemaName is schemaName or alias
65
+ const ref = currentSchema.getReferenceSync(schemaName);
66
+ const refName = currentSchema.getReferenceNameByAlias(schemaName);
67
+ if (ref) {
68
+ // Got schema by schemaName
69
+ schemaName = ref.name;
70
+ }
71
+ else if (refName) {
72
+ // Got schema by alias
73
+ schemaName = refName;
74
+ }
75
+ else {
76
+ // Didn't match any referenced schema, check if it is current schemaName or alias
77
+ if (schemaName === currentSchema.name || schemaName === currentSchema.alias)
78
+ schemaName = currentSchema.name;
79
+ }
80
+ // Create schema key with schema name
81
+ const schemaKey = new SchemaKey_1.SchemaKey(schemaName);
82
+ // Get schema with schema key
83
+ const schema = await this._context.getSchema(schemaKey);
84
+ if (!schema) {
85
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Cannot find schema", () => {
86
+ return { schema: schemaName };
87
+ });
88
+ }
89
+ else {
90
+ // Set currentSchema to look up schemaItem to be whatever is prefixed in name
91
+ currentSchema = schema;
92
+ }
93
+ // Update name to not have prefix
94
+ name = schemaItemName;
95
+ }
96
+ // Create schema item key with name and schema
97
+ const itemKey = new SchemaKey_1.SchemaItemKey(name, currentSchema.schemaKey);
98
+ // Get schema item with schema item key
99
+ const item = await this._context.getSchemaItem(itemKey);
100
+ if (!item)
101
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Cannot find schema item", () => {
102
+ return { item: name };
103
+ });
104
+ if (item.schemaItemType === ECObjects_1.SchemaItemType.Unit || item.schemaItemType === ECObjects_1.SchemaItemType.Constant)
105
+ return item;
106
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Item is neither a unit or a constant", () => {
107
+ return { itemType: item.key.fullName };
108
+ });
109
+ }
110
+ /**
111
+ * Adds unit and corresponding children to graph as well as edges between units
112
+ * @param unit Current unit to be added to graph
113
+ */
114
+ async addUnit(unit) {
115
+ if (this._graph.hasNode(unit.key.fullName))
116
+ return;
117
+ this._graph.setNode(unit.key.fullName, unit);
118
+ if (this.isIdentity(unit))
119
+ return;
120
+ const umap = (0, Parser_1.parseDefinition)(unit.definition);
121
+ const promiseArray = [];
122
+ for (const [key, value] of umap) {
123
+ promiseArray.push(this.resolveUnit(key, unit.schema).then((u) => [u, value]));
124
+ }
125
+ const resolved = await Promise.all(promiseArray);
126
+ const children = resolved.map(async ([u, def]) => {
127
+ await this.addUnit(u);
128
+ this._graph.setEdge(unit.key.fullName, u.key.fullName, {
129
+ exponent: def.exponent,
130
+ });
131
+ });
132
+ await Promise.all(children);
133
+ }
134
+ isIdentity(unit) {
135
+ return unit.definition === unit.name;
136
+ }
137
+ /**
138
+ * Reduce the tree to produce a single map
139
+ * @param unit Unit to be processed
140
+ * @param stopNodes The tree exploration should stop here
141
+ */
142
+ reduce(unit, baseUnitsMap) {
143
+ const unitFullName = unit.key.fullName;
144
+ const innerMapStore = new Map();
145
+ const outerMapStore = GraphUtils.dfsReduce(this._graph, unitFullName, (p, c) => this.reducingFunction(p, c), innerMapStore, baseUnitsMap, 1);
146
+ return outerMapStore;
147
+ }
148
+ reducingFunction(innermapStore, unitFullName) {
149
+ const outEdges = this._graph.outEdges(unitFullName);
150
+ if (outEdges) {
151
+ const cmap = outEdges.reduce((pm, e) => {
152
+ const { exponent } = this._graph.edge(e.v, e.w);
153
+ const stored = innermapStore.get(e.w);
154
+ const map = stored ? stored : UnitConversion_1.UnitConversion.identity;
155
+ const emap = map.raise(exponent);
156
+ return pm ? pm.multiply(emap) : emap;
157
+ }, undefined);
158
+ const thisMap = this._graph.node(unitFullName) ? UnitConversion_1.UnitConversion.from(this._graph.node(unitFullName)) : UnitConversion_1.UnitConversion.identity;
159
+ const other = cmap || UnitConversion_1.UnitConversion.identity;
160
+ const result = other.compose(thisMap);
161
+ innermapStore.set(unitFullName, result);
162
+ }
163
+ else {
164
+ innermapStore.set(unitFullName, UnitConversion_1.UnitConversion.identity);
165
+ }
166
+ return innermapStore;
167
+ }
168
+ }
169
+ exports.UnitGraph = UnitGraph;
170
170
  //# sourceMappingURL=UnitTree.js.map
@@ -1,78 +1,78 @@
1
- import { UnitConversion, UnitExtraData, UnitProps, UnitsProvider } from "@itwin/core-quantity";
2
- import { ISchemaLocater } from "../Context";
3
- /**
4
- * Class used to find Units in SchemaContext by attributes such as Phenomenon and DisplayLabel.
5
- * @alpha
6
- */
7
- export declare class SchemaUnitProvider implements UnitsProvider {
8
- private _unitExtraData;
9
- private _unitConverter;
10
- private _context;
11
- /**
12
- *
13
- * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext
14
- * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be
15
- * created and the locater will be added.
16
- * @param _unitExtraData Additional data like alternate display label not found in Units Schema to match with Units; Defaults to empty array.
17
- */
18
- constructor(contextOrLocater: ISchemaLocater, _unitExtraData?: UnitExtraData[]);
19
- /**
20
- * Find unit in a schema that has unitName.
21
- * @param unitName Full name of unit.
22
- * @returns UnitProps interface from @itwin/core-quantity whose name matches unitName.
23
- */
24
- findUnitByName(unitName: string): Promise<UnitProps>;
25
- /**
26
- * Find all units in context that belongs to given phenomenon.
27
- * @param phenomenon Full name of phenomenon.
28
- * @returns Array of UnitProps (from @itwin/core-quantity) interface objects whose name matches phenomenon param.
29
- */
30
- getUnitsByFamily(phenomenon: string): Promise<Array<UnitProps>>;
31
- /**
32
- * Find alternate display labels associated with unitName, if any.
33
- * @param unitName Full name of Unit.
34
- */
35
- getAlternateDisplayLabels(unitName: string): Array<string>;
36
- /**
37
- * Finds Unit by unitLabel, which could be a display label in the schema or alternate an display label defined in
38
- * this._unitExtraData. If there are duplicates of the same display label in the context or teh same alternate display
39
- * labels, specify schemaName, phenomenon, or unitSystem to get a specific unit.
40
- *
41
- * @param unitLabel Display label or alternate display label to query unit by.
42
- * @param schemaName Ensure Unit with unitLabel belongs to Schema with schemaName.
43
- * @param phenomenon Full name of phenomenon that Unit belongs to.
44
- * @param unitSystem Full name of unitSystem that Unit belongs to.
45
- * @returns The UnitProps interface from the @itwin/core-quantity package.
46
- */
47
- findUnit(unitLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps>;
48
- /**
49
- * Gets the @itwin/core-quantity UnitConversion for the given fromUnit and toUnit.
50
- * @param fromUnit The UnitProps of the 'from' unit.
51
- * @param toUnit The UnitProps of the 'to' unit.
52
- * @returns The UnitConversion interface from the @itwin/core-quantity package.
53
- */
54
- getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversion>;
55
- /**
56
- * Find unit in a schema that has unitName.
57
- * @param unitName Full name of unit.
58
- * @returns Unit whose full name matches unitName.
59
- */
60
- private findECUnitByName;
61
- /**
62
- * Gets the @itwin/core UnitProps for the given Unit.
63
- * @param unit The Unit to convert.
64
- * @returns UnitProps interface from @itwin/core.
65
- */
66
- private getUnitsProps;
67
- /**
68
- * Finds Unit by displayLabel and that it belongs to schemaName, phenomenon, and unitSystem if defined.
69
- * @internal
70
- */
71
- private findUnitByDisplayLabel;
72
- /**
73
- * Finds Unit by altDisplayLabel and that it belongs to schemaName, phenomenon, and unitSystem if defined.
74
- * @internal
75
- */
76
- private findUnitByAltDisplayLabel;
77
- }
1
+ import { UnitConversion, UnitExtraData, UnitProps, UnitsProvider } from "@itwin/core-quantity";
2
+ import { ISchemaLocater } from "../Context";
3
+ /**
4
+ * Class used to find Units in SchemaContext by attributes such as Phenomenon and DisplayLabel.
5
+ * @alpha
6
+ */
7
+ export declare class SchemaUnitProvider implements UnitsProvider {
8
+ private _unitExtraData;
9
+ private _unitConverter;
10
+ private _context;
11
+ /**
12
+ *
13
+ * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext
14
+ * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be
15
+ * created and the locater will be added.
16
+ * @param _unitExtraData Additional data like alternate display label not found in Units Schema to match with Units; Defaults to empty array.
17
+ */
18
+ constructor(contextOrLocater: ISchemaLocater, _unitExtraData?: UnitExtraData[]);
19
+ /**
20
+ * Find unit in a schema that has unitName.
21
+ * @param unitName Full name of unit.
22
+ * @returns UnitProps interface from @itwin/core-quantity whose name matches unitName.
23
+ */
24
+ findUnitByName(unitName: string): Promise<UnitProps>;
25
+ /**
26
+ * Find all units in context that belongs to given phenomenon.
27
+ * @param phenomenon Full name of phenomenon.
28
+ * @returns Array of UnitProps (from @itwin/core-quantity) interface objects whose name matches phenomenon param.
29
+ */
30
+ getUnitsByFamily(phenomenon: string): Promise<Array<UnitProps>>;
31
+ /**
32
+ * Find alternate display labels associated with unitName, if any.
33
+ * @param unitName Full name of Unit.
34
+ */
35
+ getAlternateDisplayLabels(unitName: string): Array<string>;
36
+ /**
37
+ * Finds Unit by unitLabel, which could be a display label in the schema or alternate an display label defined in
38
+ * this._unitExtraData. If there are duplicates of the same display label in the context or teh same alternate display
39
+ * labels, specify schemaName, phenomenon, or unitSystem to get a specific unit.
40
+ *
41
+ * @param unitLabel Display label or alternate display label to query unit by.
42
+ * @param schemaName Ensure Unit with unitLabel belongs to Schema with schemaName.
43
+ * @param phenomenon Full name of phenomenon that Unit belongs to.
44
+ * @param unitSystem Full name of unitSystem that Unit belongs to.
45
+ * @returns The UnitProps interface from the @itwin/core-quantity package.
46
+ */
47
+ findUnit(unitLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps>;
48
+ /**
49
+ * Gets the @itwin/core-quantity UnitConversion for the given fromUnit and toUnit.
50
+ * @param fromUnit The UnitProps of the 'from' unit.
51
+ * @param toUnit The UnitProps of the 'to' unit.
52
+ * @returns The UnitConversion interface from the @itwin/core-quantity package.
53
+ */
54
+ getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversion>;
55
+ /**
56
+ * Find unit in a schema that has unitName.
57
+ * @param unitName Full name of unit.
58
+ * @returns Unit whose full name matches unitName.
59
+ */
60
+ private findECUnitByName;
61
+ /**
62
+ * Gets the @itwin/core UnitProps for the given Unit.
63
+ * @param unit The Unit to convert.
64
+ * @returns UnitProps interface from @itwin/core.
65
+ */
66
+ private getUnitsProps;
67
+ /**
68
+ * Finds Unit by displayLabel and that it belongs to schemaName, phenomenon, and unitSystem if defined.
69
+ * @internal
70
+ */
71
+ private findUnitByDisplayLabel;
72
+ /**
73
+ * Finds Unit by altDisplayLabel and that it belongs to schemaName, phenomenon, and unitSystem if defined.
74
+ * @internal
75
+ */
76
+ private findUnitByAltDisplayLabel;
77
+ }
78
78
  //# sourceMappingURL=SchemaUnitProvider.d.ts.map