@itwin/ecschema-editing 3.4.0-dev.9 → 3.5.0-dev.4

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 (167) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/lib/cjs/Editing/Constants.d.ts +20 -20
  3. package/lib/cjs/Editing/Constants.d.ts.map +1 -1
  4. package/lib/cjs/Editing/Constants.js +60 -64
  5. package/lib/cjs/Editing/Constants.js.map +1 -1
  6. package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
  7. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  8. package/lib/cjs/Editing/CustomAttributes.js +59 -62
  9. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  10. package/lib/cjs/Editing/ECClasses.d.ts +54 -54
  11. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  12. package/lib/cjs/Editing/ECClasses.js +269 -269
  13. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  14. package/lib/cjs/Editing/Editor.d.ts +112 -112
  15. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  16. package/lib/cjs/Editing/Editor.js +166 -166
  17. package/lib/cjs/Editing/Editor.js.map +1 -1
  18. package/lib/cjs/Editing/Entities.d.ts +25 -25
  19. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  20. package/lib/cjs/Editing/Entities.js +116 -124
  21. package/lib/cjs/Editing/Entities.js.map +1 -1
  22. package/lib/cjs/Editing/Enumerations.d.ts +21 -21
  23. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  24. package/lib/cjs/Editing/Enumerations.js +66 -76
  25. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  26. package/lib/cjs/Editing/Formats.d.ts +21 -21
  27. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  28. package/lib/cjs/Editing/Formats.js +61 -63
  29. package/lib/cjs/Editing/Formats.js.map +1 -1
  30. package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
  31. package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
  32. package/lib/cjs/Editing/InvertedUnits.js +82 -85
  33. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  34. package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
  35. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  36. package/lib/cjs/Editing/KindOfQuantities.js +78 -79
  37. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  38. package/lib/cjs/Editing/Mixins.d.ts +22 -22
  39. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  40. package/lib/cjs/Editing/Mixins.js +84 -88
  41. package/lib/cjs/Editing/Mixins.js.map +1 -1
  42. package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
  43. package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
  44. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  45. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
  46. package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
  47. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  48. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
  49. package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
  50. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  51. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
  52. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
  53. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  54. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
  55. package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
  56. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  57. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
  58. package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
  59. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  60. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
  61. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
  62. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  63. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
  64. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
  65. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  66. package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
  67. package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
  68. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  69. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
  70. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
  71. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  72. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
  73. package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
  74. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  75. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
  76. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
  77. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  78. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
  79. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
  80. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  81. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
  82. package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
  83. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  84. package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
  85. package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
  86. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  87. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
  88. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
  89. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  90. package/lib/cjs/Editing/Phenomena.d.ts +15 -15
  91. package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
  92. package/lib/cjs/Editing/Phenomena.js +44 -47
  93. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  94. package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
  95. package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
  96. package/lib/cjs/Editing/PropertyCategories.js +51 -53
  97. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  98. package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
  99. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  100. package/lib/cjs/Editing/RelationshipClasses.js +68 -69
  101. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  102. package/lib/cjs/Editing/Structs.d.ts +19 -19
  103. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  104. package/lib/cjs/Editing/Structs.js +57 -60
  105. package/lib/cjs/Editing/Structs.js.map +1 -1
  106. package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
  107. package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
  108. package/lib/cjs/Editing/UnitSystems.js +41 -43
  109. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  110. package/lib/cjs/Editing/Units.d.ts +15 -15
  111. package/lib/cjs/Editing/Units.d.ts.map +1 -1
  112. package/lib/cjs/Editing/Units.js +58 -61
  113. package/lib/cjs/Editing/Units.js.map +1 -1
  114. package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
  115. package/lib/cjs/Validation/Diagnostic.js +310 -310
  116. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  117. package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
  118. package/lib/cjs/Validation/DiagnosticReporter.d.ts.map +1 -1
  119. package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
  120. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  121. package/lib/cjs/Validation/ECRules.d.ts +448 -438
  122. package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
  123. package/lib/cjs/Validation/ECRules.js +593 -583
  124. package/lib/cjs/Validation/ECRules.js.map +1 -1
  125. package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
  126. package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
  127. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  128. package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -58
  129. package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
  130. package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
  131. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  132. package/lib/cjs/Validation/Rules.d.ts +64 -64
  133. package/lib/cjs/Validation/Rules.js +9 -9
  134. package/lib/cjs/Validation/Rules.js.map +1 -1
  135. package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
  136. package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
  137. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  138. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
  139. package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
  140. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  141. package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
  142. package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
  143. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  144. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
  145. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
  146. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  147. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
  148. package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
  149. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  150. package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
  151. package/lib/cjs/Validation/SchemaComparer.js +666 -666
  152. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  153. package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
  154. package/lib/cjs/Validation/SchemaValidater.js +61 -61
  155. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  156. package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
  157. package/lib/cjs/Validation/SchemaValidationVisitor.d.ts.map +1 -1
  158. package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -490
  159. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  160. package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
  161. package/lib/cjs/Validation/SchemaWalker.js +51 -51
  162. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  163. package/lib/cjs/ecschema-editing.d.ts +33 -33
  164. package/lib/cjs/ecschema-editing.js +54 -54
  165. package/lib/cjs/ecschema-editing.js.map +1 -1
  166. package/package.json +11 -11
  167. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1,86 +1,83 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Editing
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.InvertedUnits = void 0;
11
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
- /**
13
- * @alpha
14
- * A class allowing you to create schema items of type Inverted Unit.
15
- */
16
- class InvertedUnits {
17
- constructor(_schemaEditor) {
18
- this._schemaEditor = _schemaEditor;
19
- }
20
- async create(schemaKey, name, invertsUnitKey, unitSystemKey, displayLabel) {
21
- const schema = await this._schemaEditor.getSchema(schemaKey);
22
- if (schema === undefined)
23
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
24
- const newUnit = (await schema.createInvertedUnit(name));
25
- if (newUnit === undefined) {
26
- return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
27
- }
28
- const invertsUnit = await schema.lookupItem(invertsUnitKey);
29
- if (invertsUnit === undefined)
30
- return { errorMessage: `Unable to locate unit ${invertsUnitKey.fullName} in schema ${schema.fullName}.` };
31
- if (invertsUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit)
32
- return { errorMessage: `${invertsUnit.fullName} is not of type Unit.` };
33
- newUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
34
- const unitSystem = await schema.lookupItem(unitSystemKey);
35
- if (unitSystem === undefined)
36
- return { errorMessage: `Unable to locate unit system ${unitSystemKey.fullName} in schema ${schema.fullName}.` };
37
- if (unitSystem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
38
- return { errorMessage: `${unitSystemKey.fullName} is not of type Unit System.` };
39
- newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
40
- if (displayLabel) {
41
- newUnit.setDisplayLabel(displayLabel);
42
- }
43
- return { itemKey: newUnit.key };
44
- }
45
- async createFromProps(schemaKey, invertedUnitProps) {
46
- const schema = await this._schemaEditor.getSchema(schemaKey);
47
- if (schema === undefined)
48
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
49
- if (invertedUnitProps.name === undefined)
50
- return { errorMessage: `No name was supplied within props.` };
51
- const newUnit = (await schema.createInvertedUnit(invertedUnitProps.name));
52
- if (newUnit === undefined) {
53
- return { errorMessage: `Failed to create class ${invertedUnitProps.name} in schema ${schemaKey.toString(true)}.` };
54
- }
55
- await newUnit.fromJSON(invertedUnitProps);
56
- return { itemKey: newUnit.key };
57
- }
58
- async setInvertsUnit(invertedUnitKey, invertsUnitKey) {
59
- const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertedUnitKey);
60
- if (invertedUnit === undefined)
61
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);
62
- if (invertedUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
63
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);
64
- const invertsUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertsUnitKey);
65
- if (invertsUnit === undefined)
66
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Unit ${invertsUnitKey.fullName} not found in schema context.`);
67
- if (invertsUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit)
68
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertsUnitKey.fullName} to be of type Unit.`);
69
- invertedUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
70
- }
71
- async setUnitSystem(invertedUnitKey, unitSystemKey) {
72
- const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertedUnitKey);
73
- if (invertedUnit === undefined)
74
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);
75
- if (invertedUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
76
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);
77
- const unitSystem = await this._schemaEditor.schemaContext.getSchemaItem(unitSystemKey);
78
- if (unitSystem === undefined)
79
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Unit ${unitSystemKey.fullName} not found in schema context.`);
80
- if (unitSystem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
81
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${unitSystemKey.fullName} to be of type Unit System.`);
82
- invertedUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
83
- }
84
- }
85
- exports.InvertedUnits = InvertedUnits;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Editing
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.InvertedUnits = void 0;
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ /**
13
+ * @alpha
14
+ * A class allowing you to create schema items of type Inverted Unit.
15
+ */
16
+ class InvertedUnits {
17
+ constructor(_schemaEditor) {
18
+ this._schemaEditor = _schemaEditor;
19
+ }
20
+ async create(schemaKey, name, invertsUnitKey, unitSystemKey, displayLabel) {
21
+ const schema = await this._schemaEditor.getSchema(schemaKey);
22
+ if (schema === undefined)
23
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
24
+ const newUnit = (await schema.createInvertedUnit(name));
25
+ if (newUnit === undefined)
26
+ return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
27
+ const invertsUnit = await schema.lookupItem(invertsUnitKey);
28
+ if (invertsUnit === undefined)
29
+ return { errorMessage: `Unable to locate unit ${invertsUnitKey.fullName} in schema ${schema.fullName}.` };
30
+ if (invertsUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit)
31
+ return { errorMessage: `${invertsUnit.fullName} is not of type Unit.` };
32
+ newUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
33
+ const unitSystem = await schema.lookupItem(unitSystemKey);
34
+ if (unitSystem === undefined)
35
+ return { errorMessage: `Unable to locate unit system ${unitSystemKey.fullName} in schema ${schema.fullName}.` };
36
+ if (unitSystem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
37
+ return { errorMessage: `${unitSystemKey.fullName} is not of type Unit System.` };
38
+ newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
39
+ if (displayLabel)
40
+ newUnit.setDisplayLabel(displayLabel);
41
+ return { itemKey: newUnit.key };
42
+ }
43
+ async createFromProps(schemaKey, invertedUnitProps) {
44
+ const schema = await this._schemaEditor.getSchema(schemaKey);
45
+ if (schema === undefined)
46
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
47
+ if (invertedUnitProps.name === undefined)
48
+ return { errorMessage: `No name was supplied within props.` };
49
+ const newUnit = (await schema.createInvertedUnit(invertedUnitProps.name));
50
+ if (newUnit === undefined)
51
+ return { errorMessage: `Failed to create class ${invertedUnitProps.name} in schema ${schemaKey.toString(true)}.` };
52
+ await newUnit.fromJSON(invertedUnitProps);
53
+ return { itemKey: newUnit.key };
54
+ }
55
+ async setInvertsUnit(invertedUnitKey, invertsUnitKey) {
56
+ const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertedUnitKey);
57
+ if (invertedUnit === undefined)
58
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);
59
+ if (invertedUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
60
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);
61
+ const invertsUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertsUnitKey);
62
+ if (invertsUnit === undefined)
63
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Unit ${invertsUnitKey.fullName} not found in schema context.`);
64
+ if (invertsUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit)
65
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertsUnitKey.fullName} to be of type Unit.`);
66
+ invertedUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
67
+ }
68
+ async setUnitSystem(invertedUnitKey, unitSystemKey) {
69
+ const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertedUnitKey);
70
+ if (invertedUnit === undefined)
71
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);
72
+ if (invertedUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
73
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);
74
+ const unitSystem = await this._schemaEditor.schemaContext.getSchemaItem(unitSystemKey);
75
+ if (unitSystem === undefined)
76
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Unit ${unitSystemKey.fullName} not found in schema context.`);
77
+ if (unitSystem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
78
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${unitSystemKey.fullName} to be of type Unit System.`);
79
+ invertedUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
80
+ }
81
+ }
82
+ exports.InvertedUnits = InvertedUnits;
86
83
  //# sourceMappingURL=InvertedUnits.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InvertedUnits.js","sourceRoot":"","sources":["../../../src/Editing/InvertedUnits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAIlC;;;GAGG;AACH,MAAa,aAAa;IACxB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,cAA6B,EAAE,aAA4B,EAAE,YAAqB;QACxI,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEjH,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAwB,CAAC;QAC/E,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;SAClG;QAED,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,UAAU,CAAO,cAAc,CAAC,CAAC;QAClE,IAAI,WAAW,KAAK,SAAS;YAAE,OAAO,EAAE,YAAY,EAAE,yBAAyB,cAAc,CAAC,QAAQ,cAAc,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC;QACzI,IAAI,WAAW,CAAC,cAAc,KAAK,kCAAc,CAAC,IAAI;YAAE,OAAO,EA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,CAAC,CAAC;IACzH,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,eAA8B,EAAE,aAA4B;QACrF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAsB,eAAe,CAAC,CAAC;QAEhH,IAAI,YAAY,KAAK,SAAS;YAAE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,iBAAiB,eAAe,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAClK,IAAI,YAAY,CAAC,cAAc,KAAK,kCAAc,CAAC,YAAY;YAAE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,eAAe,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEtM,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAa,aAAa,CAAC,CAAC;QACnG,IAAI,UAAU,KAAK,SAAS;YAAE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,QAAQ,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QACrJ,IAAI,UAAU,CAAC,cAAc,KAAK,kCAAc,CAAC,UAAU;YAAE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,aAAa,CAAC,QAAQ,6BAA6B,CAAC,CAAC;QAE9L,YAAY,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,aAAa,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5H,CAAC;CACF;AAnED,sCAmEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport {\r\n DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, InvertedUnitProps, SchemaItemKey,\r\n SchemaItemType, SchemaKey, Unit, UnitSystem,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableInvertedUnit } from \"./Mutable/MutableInvertedUnit\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Inverted Unit.\r\n */\r\nexport class InvertedUnits {\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n public async create(schemaKey: SchemaKey, name: string, invertsUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined) return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n const newUnit = (await schema.createInvertedUnit(name)) as MutableInvertedUnit;\r\n if (newUnit === undefined) {\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n }\r\n\r\n const invertsUnit = await schema.lookupItem<Unit>(invertsUnitKey);\r\n if (invertsUnit === undefined) return { errorMessage: `Unable to locate unit ${invertsUnitKey.fullName} in schema ${schema.fullName}.` };\r\n if (invertsUnit.schemaItemType !== SchemaItemType.Unit) return { errorMessage: `${invertsUnit.fullName} is not of type Unit.` };\r\n\r\n newUnit.setInvertsUnit(new DelayedPromiseWithProps<SchemaItemKey, Unit>(invertsUnitKey, async () => invertsUnit));\r\n\r\n const unitSystem = await schema.lookupItem<UnitSystem>(unitSystemKey);\r\n if (unitSystem === undefined) return { errorMessage: `Unable to locate unit system ${unitSystemKey.fullName} in schema ${schema.fullName}.` };\r\n if (unitSystem.schemaItemType !== SchemaItemType.UnitSystem) return { errorMessage: `${unitSystemKey.fullName} is not of type Unit System.` };\r\n\r\n newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemKey, async () => unitSystem));\r\n\r\n if (displayLabel) { newUnit.setDisplayLabel(displayLabel); }\r\n\r\n return { itemKey: newUnit.key };\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, invertedUnitProps: InvertedUnitProps): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined) return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (invertedUnitProps.name === undefined) return { errorMessage: `No name was supplied within props.` };\r\n const newUnit = (await schema.createInvertedUnit(invertedUnitProps.name)) as MutableInvertedUnit;\r\n if (newUnit === undefined) {\r\n return { errorMessage: `Failed to create class ${invertedUnitProps.name} in schema ${schemaKey.toString(true)}.` };\r\n }\r\n\r\n await newUnit.fromJSON(invertedUnitProps);\r\n return { itemKey: newUnit.key };\r\n }\r\n\r\n public async setInvertsUnit(invertedUnitKey: SchemaItemKey, invertsUnitKey: SchemaItemKey): Promise<void> {\r\n const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem<MutableInvertedUnit>(invertedUnitKey);\r\n\r\n if (invertedUnit === undefined) throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);\r\n if (invertedUnit.schemaItemType !== SchemaItemType.InvertedUnit) throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);\r\n\r\n const invertsUnit = await this._schemaEditor.schemaContext.getSchemaItem<Unit>(invertsUnitKey);\r\n if (invertsUnit === undefined) throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Unit ${invertsUnitKey.fullName} not found in schema context.`);\r\n if (invertsUnit.schemaItemType !== SchemaItemType.Unit) throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertsUnitKey.fullName} to be of type Unit.`);\r\n\r\n invertedUnit.setInvertsUnit(new DelayedPromiseWithProps<SchemaItemKey, Unit>(invertsUnitKey, async () => invertsUnit));\r\n }\r\n\r\n public async setUnitSystem(invertedUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey): Promise<void> {\r\n const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem<MutableInvertedUnit>(invertedUnitKey);\r\n\r\n if (invertedUnit === undefined) throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);\r\n if (invertedUnit.schemaItemType !== SchemaItemType.InvertedUnit) throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);\r\n\r\n const unitSystem = await this._schemaEditor.schemaContext.getSchemaItem<UnitSystem>(unitSystemKey);\r\n if (unitSystem === undefined) throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Unit ${unitSystemKey.fullName} not found in schema context.`);\r\n if (unitSystem.schemaItemType !== SchemaItemType.UnitSystem) throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${unitSystemKey.fullName} to be of type Unit System.`);\r\n\r\n invertedUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemKey, async () => unitSystem));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"InvertedUnits.js","sourceRoot":"","sources":["../../../src/Editing/InvertedUnits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAIlC;;;GAGG;AACH,MAAa,aAAa;IACxB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,cAA6B,EAAE,aAA4B,EAAE,YAAqB;QACxI,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QA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AAC,UAAU;YACzD,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,aAAa,CAAC,QAAQ,6BAA6B,CAAC,CAAC;QAEnI,YAAY,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,aAAa,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5H,CAAC;CACF;AAxFD,sCAwFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, InvertedUnitProps, SchemaItemKey,\n SchemaItemType, SchemaKey, Unit, UnitSystem,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableInvertedUnit } from \"./Mutable/MutableInvertedUnit\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Inverted Unit.\n */\nexport class InvertedUnits {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async create(schemaKey: SchemaKey, name: string, invertsUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newUnit = (await schema.createInvertedUnit(name)) as MutableInvertedUnit;\n if (newUnit === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n const invertsUnit = await schema.lookupItem<Unit>(invertsUnitKey);\n if (invertsUnit === undefined)\n return { errorMessage: `Unable to locate unit ${invertsUnitKey.fullName} in schema ${schema.fullName}.` };\n\n if (invertsUnit.schemaItemType !== SchemaItemType.Unit)\n return { errorMessage: `${invertsUnit.fullName} is not of type Unit.` };\n\n newUnit.setInvertsUnit(new DelayedPromiseWithProps<SchemaItemKey, Unit>(invertsUnitKey, async () => invertsUnit));\n\n const unitSystem = await schema.lookupItem<UnitSystem>(unitSystemKey);\n if (unitSystem === undefined)\n return { errorMessage: `Unable to locate unit system ${unitSystemKey.fullName} in schema ${schema.fullName}.` };\n\n if (unitSystem.schemaItemType !== SchemaItemType.UnitSystem)\n return { errorMessage: `${unitSystemKey.fullName} is not of type Unit System.` };\n\n newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemKey, async () => unitSystem));\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return { itemKey: newUnit.key };\n }\n\n public async createFromProps(schemaKey: SchemaKey, invertedUnitProps: InvertedUnitProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (invertedUnitProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newUnit = (await schema.createInvertedUnit(invertedUnitProps.name)) as MutableInvertedUnit;\n if (newUnit === undefined)\n return { errorMessage: `Failed to create class ${invertedUnitProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newUnit.fromJSON(invertedUnitProps);\n return { itemKey: newUnit.key };\n }\n\n public async setInvertsUnit(invertedUnitKey: SchemaItemKey, invertsUnitKey: SchemaItemKey): Promise<void> {\n const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem<MutableInvertedUnit>(invertedUnitKey);\n\n if (invertedUnit === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);\n\n if (invertedUnit.schemaItemType !== SchemaItemType.InvertedUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);\n\n const invertsUnit = await this._schemaEditor.schemaContext.getSchemaItem<Unit>(invertsUnitKey);\n if (invertsUnit === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Unit ${invertsUnitKey.fullName} not found in schema context.`);\n\n if (invertsUnit.schemaItemType !== SchemaItemType.Unit)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertsUnitKey.fullName} to be of type Unit.`);\n\n invertedUnit.setInvertsUnit(new DelayedPromiseWithProps<SchemaItemKey, Unit>(invertsUnitKey, async () => invertsUnit));\n }\n\n public async setUnitSystem(invertedUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey): Promise<void> {\n const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem<MutableInvertedUnit>(invertedUnitKey);\n\n if (invertedUnit === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);\n\n if (invertedUnit.schemaItemType !== SchemaItemType.InvertedUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);\n\n const unitSystem = await this._schemaEditor.schemaContext.getSchemaItem<UnitSystem>(unitSystemKey);\n if (unitSystem === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Unit ${unitSystemKey.fullName} not found in schema context.`);\n\n if (unitSystem.schemaItemType !== SchemaItemType.UnitSystem)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${unitSystemKey.fullName} to be of type Unit System.`);\n\n invertedUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemKey, async () => unitSystem));\n }\n}\n"]}
@@ -1,29 +1,29 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { InvertedUnit, KindOfQuantityProps, OverrideFormat, SchemaItemKey, SchemaKey, Unit } from "@itwin/ecschema-metadata";
5
- import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
- /**
7
- * @alpha
8
- * A class allowing you to create schema items of type KindOfQuantity.
9
- */
10
- export declare class KindOfQuantities {
11
- protected _schemaEditor: SchemaContextEditor;
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemEditResults>;
14
- /**
15
- *
16
- * @param koqKey A schemaItemKey of the editing KindOfQuantity.
17
- * @param format A schemaItemKey of a Format.
18
- * @param isDefault .is set to false when not explicitly passed.
19
- */
20
- addPresentationFormat(koqKey: SchemaItemKey, format: SchemaItemKey, isDefault?: boolean): Promise<void>;
21
- addPresentationOverrideFormat(koqKey: SchemaItemKey, overrideFormat: OverrideFormat, isDefault?: boolean): Promise<void>;
22
- /**
23
- * @param koqKey A schemaItemKey of the editing KindOfQuantity.
24
- * @param parent A SchemaItemKey of the parent Format.
25
- * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
26
- */
27
- createFormatOverride(koqKey: SchemaItemKey, parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat>;
28
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { InvertedUnit, KindOfQuantityProps, OverrideFormat, SchemaItemKey, SchemaKey, Unit } from "@itwin/ecschema-metadata";
5
+ import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ /**
7
+ * @alpha
8
+ * A class allowing you to create schema items of type KindOfQuantity.
9
+ */
10
+ export declare class KindOfQuantities {
11
+ protected _schemaEditor: SchemaContextEditor;
12
+ constructor(_schemaEditor: SchemaContextEditor);
13
+ createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemEditResults>;
14
+ /**
15
+ *
16
+ * @param koqKey A schemaItemKey of the editing KindOfQuantity.
17
+ * @param format A schemaItemKey of a Format.
18
+ * @param isDefault .is set to false when not explicitly passed.
19
+ */
20
+ addPresentationFormat(koqKey: SchemaItemKey, format: SchemaItemKey, isDefault?: boolean): Promise<void>;
21
+ addPresentationOverrideFormat(koqKey: SchemaItemKey, overrideFormat: OverrideFormat, isDefault?: boolean): Promise<void>;
22
+ /**
23
+ * @param koqKey A schemaItemKey of the editing KindOfQuantity.
24
+ * @param parent A SchemaItemKey of the parent Format.
25
+ * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
26
+ */
27
+ createFormatOverride(koqKey: SchemaItemKey, parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat>;
28
+ }
29
29
  //# sourceMappingURL=KindOfQuantities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantities.d.ts","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACoC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAC1F,aAAa,EAAkB,SAAS,EAAE,IAAI,EAC/C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,qBAAa,gBAAgB;IACR,SAAS,CAAC,aAAa,EAAE,mBAAmB;gBAAlC,aAAa,EAAE,mBAAmB;IAClD,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAcjH;;;;;OAKG;IACU,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAc9G,6BAA6B,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5I;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;CAapM"}
1
+ {"version":3,"file":"KindOfQuantities.d.ts","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACoC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAC1F,aAAa,EAAkB,SAAS,EAAE,IAAI,EAC/C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,qBAAa,gBAAgB;IACR,SAAS,CAAC,aAAa,EAAE,mBAAmB;gBAAlC,aAAa,EAAE,mBAAmB;IAClD,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgBjH;;;;;OAKG;IACU,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB9G,6BAA6B,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAY5I;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;CAkBpM"}
@@ -1,80 +1,79 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Editing
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.KindOfQuantities = void 0;
11
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
- /**
13
- * @alpha
14
- * A class allowing you to create schema items of type KindOfQuantity.
15
- */
16
- class KindOfQuantities {
17
- constructor(_schemaEditor) {
18
- this._schemaEditor = _schemaEditor;
19
- }
20
- async createFromProps(schemaKey, koqProps) {
21
- const schema = await this._schemaEditor.getSchema(schemaKey);
22
- if (schema === undefined)
23
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
24
- if (koqProps.name === undefined)
25
- return { errorMessage: `No name was supplied within props.` };
26
- const newKoQ = (await schema.createKindOfQuantity(koqProps.name));
27
- if (newKoQ === undefined) {
28
- return { errorMessage: `Failed to create class ${koqProps.name} in schema ${schemaKey.toString(true)}.` };
29
- }
30
- await newKoQ.fromJSON(koqProps);
31
- return { itemKey: newKoQ.key };
32
- }
33
- /**
34
- *
35
- * @param koqKey A schemaItemKey of the editing KindOfQuantity.
36
- * @param format A schemaItemKey of a Format.
37
- * @param isDefault .is set to false when not explicitly passed.
38
- */
39
- async addPresentationFormat(koqKey, format, isDefault = false) {
40
- const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
41
- if (kindOfQuantity === undefined)
42
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
43
- if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
44
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
45
- const presentationFormat = await (this._schemaEditor.schemaContext.getSchemaItem(format));
46
- if (undefined === presentationFormat)
47
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${format.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
48
- if (presentationFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
49
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${presentationFormat.fullName} to be of type Format.`);
50
- kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);
51
- }
52
- async addPresentationOverrideFormat(koqKey, overrideFormat, isDefault = false) {
53
- const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
54
- if (kindOfQuantity === undefined)
55
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
56
- if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
57
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
58
- kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);
59
- }
60
- /**
61
- * @param koqKey A schemaItemKey of the editing KindOfQuantity.
62
- * @param parent A SchemaItemKey of the parent Format.
63
- * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
64
- */
65
- async createFormatOverride(koqKey, parent, precision, unitLabelOverrides) {
66
- const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
67
- if (kindOfQuantity === undefined)
68
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
69
- if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
70
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
71
- const parentFormat = await (this._schemaEditor.schemaContext.getSchemaItem(parent));
72
- if (undefined === parentFormat)
73
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${parent.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
74
- if (parentFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
75
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${parentFormat.fullName} to be of type Format.`);
76
- return new ecschema_metadata_1.OverrideFormat(parentFormat, precision, unitLabelOverrides);
77
- }
78
- }
79
- exports.KindOfQuantities = KindOfQuantities;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Editing
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.KindOfQuantities = void 0;
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ /**
13
+ * @alpha
14
+ * A class allowing you to create schema items of type KindOfQuantity.
15
+ */
16
+ class KindOfQuantities {
17
+ constructor(_schemaEditor) {
18
+ this._schemaEditor = _schemaEditor;
19
+ }
20
+ async createFromProps(schemaKey, koqProps) {
21
+ const schema = await this._schemaEditor.getSchema(schemaKey);
22
+ if (schema === undefined)
23
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
24
+ if (koqProps.name === undefined)
25
+ return { errorMessage: `No name was supplied within props.` };
26
+ const newKoQ = (await schema.createKindOfQuantity(koqProps.name));
27
+ if (newKoQ === undefined)
28
+ return { errorMessage: `Failed to create class ${koqProps.name} in schema ${schemaKey.toString(true)}.` };
29
+ await newKoQ.fromJSON(koqProps);
30
+ return { itemKey: newKoQ.key };
31
+ }
32
+ /**
33
+ *
34
+ * @param koqKey A schemaItemKey of the editing KindOfQuantity.
35
+ * @param format A schemaItemKey of a Format.
36
+ * @param isDefault .is set to false when not explicitly passed.
37
+ */
38
+ async addPresentationFormat(koqKey, format, isDefault = false) {
39
+ const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
40
+ if (kindOfQuantity === undefined)
41
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
42
+ if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
43
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
44
+ const presentationFormat = await (this._schemaEditor.schemaContext.getSchemaItem(format));
45
+ if (undefined === presentationFormat)
46
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${format.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
47
+ if (presentationFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
48
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${presentationFormat.fullName} to be of type Format.`);
49
+ kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);
50
+ }
51
+ async addPresentationOverrideFormat(koqKey, overrideFormat, isDefault = false) {
52
+ const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
53
+ if (kindOfQuantity === undefined)
54
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
55
+ if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
56
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
57
+ kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);
58
+ }
59
+ /**
60
+ * @param koqKey A schemaItemKey of the editing KindOfQuantity.
61
+ * @param parent A SchemaItemKey of the parent Format.
62
+ * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
63
+ */
64
+ async createFormatOverride(koqKey, parent, precision, unitLabelOverrides) {
65
+ const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
66
+ if (kindOfQuantity === undefined)
67
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
68
+ if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
69
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
70
+ const parentFormat = await (this._schemaEditor.schemaContext.getSchemaItem(parent));
71
+ if (undefined === parentFormat)
72
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${parent.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
73
+ if (parentFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
74
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${parentFormat.fullName} to be of type Format.`);
75
+ return new ecschema_metadata_1.OverrideFormat(parentFormat, precision, unitLabelOverrides);
76
+ }
77
+ }
78
+ exports.KindOfQuantities = KindOfQuantities;
80
79
  //# sourceMappingURL=KindOfQuantities.js.map
@@ -1 +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AAkC,CAAC,CAAC;QAEpM,cAAc,CAAC,qBAAqB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,oBAAoB,CAAC,MAAqB,EAAE,MAAqB,EAAE,SAAkB,EAAE,kBAAqE;QACvK,MAAM,cAAc,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAwB,MAAM,CAAC,CAAC,CAAC;QAE7G,IAAI,cAAc,KAAK,SAAS;YAAE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,gBAAgB,MAAM,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAC1J,IAAI,cAAc,CAAC,cAAc,KAAK,kCAAc,CAAC,cAAc;YAAE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,MAAM,CAAC,QAAQ,kCAAkC,CAAC,CAAC;QAEpM,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAS,MAAM,CAAC,CAAC,CAAC;QAC5F,IAAI,SAAS,KAAK,YAAY;YAC5B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,4BAA4B,MAAM,CAAC,QAAQ,iDAAiD,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;QAC1K,IAAI,YAAY,CAAC,cAAc,KAAK,kCAAc,CAAC,MAAM;YAAE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,YAAY,CAAC,QAAQ,wBAAwB,CAAC,CAAC;QAEtL,OAAO,IAAI,kCAAc,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACzE,CAAC;CACF;AA/DD,4CA+DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport {\r\n ECObjectsError, ECObjectsStatus, Format, InvertedUnit, KindOfQuantityProps, OverrideFormat,\r\n SchemaItemKey, SchemaItemType, SchemaKey, Unit,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableKindOfQuantity } from \"./Mutable/MutableKindOfQuantity\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type KindOfQuantity.\r\n */\r\nexport class KindOfQuantities {\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n public async createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined) return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (koqProps.name === undefined) return { errorMessage: `No name was supplied within props.` };\r\n const newKoQ = (await schema.createKindOfQuantity(koqProps.name)) as MutableKindOfQuantity;\r\n if (newKoQ === undefined) {\r\n return { errorMessage: `Failed to create class ${koqProps.name} in schema ${schemaKey.toString(true)}.` };\r\n }\r\n\r\n await newKoQ.fromJSON(koqProps);\r\n return { itemKey: newKoQ.key };\r\n }\r\n\r\n /**\r\n *\r\n * @param koqKey A schemaItemKey of the editing KindOfQuantity.\r\n * @param format A schemaItemKey of a Format.\r\n * @param isDefault .is set to false when not explicitly passed.\r\n */\r\n public async addPresentationFormat(koqKey: SchemaItemKey, format: SchemaItemKey, isDefault: boolean = false): Promise<void> {\r\n const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableKindOfQuantity>(koqKey));\r\n\r\n if (kindOfQuantity === undefined) throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);\r\n if (kindOfQuantity.schemaItemType !== SchemaItemType.KindOfQuantity) throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);\r\n\r\n const presentationFormat = await (this._schemaEditor.schemaContext.getSchemaItem<Format>(format));\r\n if (undefined === presentationFormat)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate format '${format.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);\r\n if (presentationFormat.schemaItemType !== SchemaItemType.Format) throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${presentationFormat.fullName} to be of type Format.`);\r\n\r\n kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);\r\n }\r\n\r\n public async addPresentationOverrideFormat(koqKey: SchemaItemKey, overrideFormat: OverrideFormat, isDefault: boolean = false): Promise<void> {\r\n const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableKindOfQuantity>(koqKey));\r\n\r\n if (kindOfQuantity === undefined) throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);\r\n if (kindOfQuantity.schemaItemType !== SchemaItemType.KindOfQuantity) throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);\r\n\r\n kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);\r\n }\r\n\r\n /**\r\n * @param koqKey A schemaItemKey of the editing KindOfQuantity.\r\n * @param parent A SchemaItemKey of the parent Format.\r\n * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.\r\n */\r\n public async createFormatOverride(koqKey: SchemaItemKey, parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat> {\r\n const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableKindOfQuantity>(koqKey));\r\n\r\n if (kindOfQuantity === undefined) throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);\r\n if (kindOfQuantity.schemaItemType !== SchemaItemType.KindOfQuantity) throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);\r\n\r\n const parentFormat = await (this._schemaEditor.schemaContext.getSchemaItem<Format>(parent));\r\n if (undefined === parentFormat)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate format '${parent.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);\r\n if (parentFormat.schemaItemType !== SchemaItemType.Format) throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${parentFormat.fullName} to be of type Format.`);\r\n\r\n return new OverrideFormat(parentFormat, precision, unitLabelOverrides);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"KindOfQuantities.js","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAIlC;;;GAGG;AACH,MAAa,gBAAgB;IAC3B,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,QAA6B;QAC9E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS;YAC7B,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAA0B,CAAC;QAC3F,IAAI,MAAM,KAAK,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AAY;YAC5B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,4BAA4B,MAAM,CAAC,QAAQ,iDAAiD,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;QAE1K,IAAI,YAAY,CAAC,cAAc,KAAK,kCAAc,CAAC,MAAM;YACvD,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,YAAY,CAAC,QAAQ,wBAAwB,CAAC,CAAC;QAE7H,OAAO,IAAI,kCAAc,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACzE,CAAC;CACF;AA9ED,4CA8EC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n ECObjectsError, ECObjectsStatus, Format, InvertedUnit, KindOfQuantityProps, OverrideFormat,\n SchemaItemKey, SchemaItemType, SchemaKey, Unit,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableKindOfQuantity } from \"./Mutable/MutableKindOfQuantity\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type KindOfQuantity.\n */\nexport class KindOfQuantities {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (koqProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newKoQ = (await schema.createKindOfQuantity(koqProps.name)) as MutableKindOfQuantity;\n if (newKoQ === undefined)\n return { errorMessage: `Failed to create class ${koqProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newKoQ.fromJSON(koqProps);\n return { itemKey: newKoQ.key };\n }\n\n /**\n *\n * @param koqKey A schemaItemKey of the editing KindOfQuantity.\n * @param format A schemaItemKey of a Format.\n * @param isDefault .is set to false when not explicitly passed.\n */\n public async addPresentationFormat(koqKey: SchemaItemKey, format: SchemaItemKey, isDefault: boolean = false): Promise<void> {\n const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableKindOfQuantity>(koqKey));\n\n if (kindOfQuantity === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);\n\n if (kindOfQuantity.schemaItemType !== SchemaItemType.KindOfQuantity)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);\n\n const presentationFormat = await (this._schemaEditor.schemaContext.getSchemaItem<Format>(format));\n if (undefined === presentationFormat)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate format '${format.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);\n\n if (presentationFormat.schemaItemType !== SchemaItemType.Format)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${presentationFormat.fullName} to be of type Format.`);\n\n kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);\n }\n\n public async addPresentationOverrideFormat(koqKey: SchemaItemKey, overrideFormat: OverrideFormat, isDefault: boolean = false): Promise<void> {\n const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableKindOfQuantity>(koqKey));\n\n if (kindOfQuantity === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);\n\n if (kindOfQuantity.schemaItemType !== SchemaItemType.KindOfQuantity)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);\n\n kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);\n }\n\n /**\n * @param koqKey A schemaItemKey of the editing KindOfQuantity.\n * @param parent A SchemaItemKey of the parent Format.\n * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.\n */\n public async createFormatOverride(koqKey: SchemaItemKey, parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat> {\n const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableKindOfQuantity>(koqKey));\n\n if (kindOfQuantity === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);\n\n if (kindOfQuantity.schemaItemType !== SchemaItemType.KindOfQuantity)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);\n\n const parentFormat = await (this._schemaEditor.schemaContext.getSchemaItem<Format>(parent));\n if (undefined === parentFormat)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate format '${parent.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);\n\n if (parentFormat.schemaItemType !== SchemaItemType.Format)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${parentFormat.fullName} to be of type Format.`);\n\n return new OverrideFormat(parentFormat, precision, unitLabelOverrides);\n }\n}\n"]}
@@ -1,23 +1,23 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { MixinProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
5
- import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
- import { ECClasses } from "./ECClasses";
7
- /**
8
- * @alpha
9
- * A class extending ECClasses allowing you to create schema items of type Mixin.
10
- */
11
- export declare class Mixins extends ECClasses {
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- create(schemaKey: SchemaKey, name: string, appliesTo: SchemaItemKey, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
14
- /**
15
- * Creates a MixinClass through a MixinProps.
16
- * @param schemaKey a SchemaKey of the Schema that will house the new object.
17
- * @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.
18
- */
19
- createFromProps(schemaKey: SchemaKey, mixinProps: MixinProps): Promise<SchemaItemEditResults>;
20
- addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void>;
21
- createNavigationProperty(mixinKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
22
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { MixinProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
5
+ import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ import { ECClasses } from "./ECClasses";
7
+ /**
8
+ * @alpha
9
+ * A class extending ECClasses allowing you to create schema items of type Mixin.
10
+ */
11
+ export declare class Mixins extends ECClasses {
12
+ constructor(_schemaEditor: SchemaContextEditor);
13
+ create(schemaKey: SchemaKey, name: string, appliesTo: SchemaItemKey, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
14
+ /**
15
+ * Creates a MixinClass through a MixinProps.
16
+ * @param schemaKey a SchemaKey of the Schema that will house the new object.
17
+ * @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.
18
+ */
19
+ createFromProps(schemaKey: SchemaKey, mixinProps: MixinProps): Promise<SchemaItemEditResults>;
20
+ addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void>;
21
+ createNavigationProperty(mixinKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
22
+ }
23
23
  //# sourceMappingURL=Mixins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Mixins.d.ts","sourceRoot":"","sources":["../../../src/Editing/Mixins.ts"],"names":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