@itwin/ecschema-editing 4.0.0-dev.6 → 4.0.0-dev.60

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 (150) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/lib/cjs/Editing/Constants.d.ts +20 -20
  3. package/lib/cjs/Editing/Constants.js +60 -60
  4. package/lib/cjs/Editing/Constants.js.map +1 -1
  5. package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
  6. package/lib/cjs/Editing/CustomAttributes.js +59 -59
  7. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  8. package/lib/cjs/Editing/ECClasses.d.ts +54 -54
  9. package/lib/cjs/Editing/ECClasses.js +269 -269
  10. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  11. package/lib/cjs/Editing/Editor.d.ts +112 -112
  12. package/lib/cjs/Editing/Editor.js +166 -166
  13. package/lib/cjs/Editing/Editor.js.map +1 -1
  14. package/lib/cjs/Editing/Entities.d.ts +25 -25
  15. package/lib/cjs/Editing/Entities.js +116 -116
  16. package/lib/cjs/Editing/Entities.js.map +1 -1
  17. package/lib/cjs/Editing/Enumerations.d.ts +21 -21
  18. package/lib/cjs/Editing/Enumerations.js +66 -66
  19. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  20. package/lib/cjs/Editing/Formats.d.ts +21 -21
  21. package/lib/cjs/Editing/Formats.js +61 -61
  22. package/lib/cjs/Editing/Formats.js.map +1 -1
  23. package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
  24. package/lib/cjs/Editing/InvertedUnits.js +82 -82
  25. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  26. package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
  27. package/lib/cjs/Editing/KindOfQuantities.js +78 -78
  28. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  29. package/lib/cjs/Editing/Mixins.d.ts +22 -22
  30. package/lib/cjs/Editing/Mixins.js +84 -84
  31. package/lib/cjs/Editing/Mixins.js.map +1 -1
  32. package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
  33. package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
  34. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  35. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
  36. package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
  37. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  38. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
  39. package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
  40. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  41. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
  42. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
  43. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  44. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
  45. package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
  46. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  47. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
  48. package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
  49. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  50. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
  51. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
  52. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  53. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
  54. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
  55. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  56. package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
  57. package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
  58. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  59. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
  60. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
  61. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  62. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
  63. package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
  64. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  65. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
  66. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
  67. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  68. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
  69. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
  70. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  71. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
  72. package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
  73. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  74. package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
  75. package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
  76. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  77. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
  78. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
  79. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  80. package/lib/cjs/Editing/Phenomena.d.ts +15 -15
  81. package/lib/cjs/Editing/Phenomena.js +44 -44
  82. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  83. package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
  84. package/lib/cjs/Editing/PropertyCategories.js +51 -51
  85. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  86. package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
  87. package/lib/cjs/Editing/RelationshipClasses.js +68 -68
  88. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  89. package/lib/cjs/Editing/Structs.d.ts +19 -19
  90. package/lib/cjs/Editing/Structs.js +57 -57
  91. package/lib/cjs/Editing/Structs.js.map +1 -1
  92. package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
  93. package/lib/cjs/Editing/UnitSystems.js +41 -41
  94. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  95. package/lib/cjs/Editing/Units.d.ts +15 -15
  96. package/lib/cjs/Editing/Units.js +58 -58
  97. package/lib/cjs/Editing/Units.js.map +1 -1
  98. package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
  99. package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
  100. package/lib/cjs/Validation/Diagnostic.js +310 -310
  101. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  102. package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
  103. package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
  104. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  105. package/lib/cjs/Validation/ECRules.d.ts +448 -448
  106. package/lib/cjs/Validation/ECRules.js +593 -593
  107. package/lib/cjs/Validation/ECRules.js.map +1 -1
  108. package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
  109. package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
  110. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  111. package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -59
  112. package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
  113. package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
  114. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  115. package/lib/cjs/Validation/Rules.d.ts +64 -64
  116. package/lib/cjs/Validation/Rules.d.ts.map +1 -1
  117. package/lib/cjs/Validation/Rules.js +9 -9
  118. package/lib/cjs/Validation/Rules.js.map +1 -1
  119. package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
  120. package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
  121. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  122. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
  123. package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
  124. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  125. package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
  126. package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
  127. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  128. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
  129. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
  130. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  131. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
  132. package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
  133. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  134. package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
  135. package/lib/cjs/Validation/SchemaComparer.js +666 -666
  136. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  137. package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
  138. package/lib/cjs/Validation/SchemaValidater.js +61 -61
  139. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  140. package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
  141. package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -492
  142. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  143. package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
  144. package/lib/cjs/Validation/SchemaWalker.js +51 -51
  145. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  146. package/lib/cjs/ecschema-editing.d.ts +33 -33
  147. package/lib/cjs/ecschema-editing.js +58 -54
  148. package/lib/cjs/ecschema-editing.js.map +1 -1
  149. package/package.json +12 -12
  150. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1,62 +1,62 @@
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.Formats = 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 Format.
15
- */
16
- class Formats {
17
- constructor(_schemaEditor) {
18
- this._schemaEditor = _schemaEditor;
19
- }
20
- async create(schemaKey, name, formatType, displayLabel, units) {
21
- const schema = await this._schemaEditor.getSchema(schemaKey);
22
- const newFormat = (await schema.createFormat(name));
23
- if (newFormat === undefined) {
24
- return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
25
- }
26
- if (units !== undefined) {
27
- for (const unit of units) {
28
- const unitItem = await this._schemaEditor.schemaContext.getSchemaItem(unit);
29
- if (unitItem === undefined) {
30
- return { errorMessage: `Failed to locate unit ${unit.name} in Schema Context.` };
31
- }
32
- if (unitItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit && unitItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
33
- return { errorMessage: `${unitItem.fullName} is not of type Unit or InvertedUnit.` };
34
- newFormat.addUnit(unitItem);
35
- }
36
- }
37
- if (displayLabel)
38
- newFormat.setDisplayLabel(displayLabel);
39
- // TODO: Handle the setting of format traits, separators, etc....
40
- newFormat.setFormatType(formatType);
41
- return { itemKey: newFormat.key };
42
- }
43
- /**
44
- * Creates a format through a FormatProps.
45
- * @param schemaKey a SchemaKey of the Schema that will house the new object.
46
- * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
47
- */
48
- async createFromProps(schemaKey, formatProps) {
49
- const schema = await this._schemaEditor.getSchema(schemaKey);
50
- if (schema === undefined)
51
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
52
- if (formatProps.name === undefined)
53
- return { errorMessage: `No name was supplied within props.` };
54
- const newFormat = (await schema.createFormat(formatProps.name));
55
- if (newFormat === undefined)
56
- return { errorMessage: `Failed to create class ${formatProps.name} in schema ${schemaKey.toString(true)}.` };
57
- await newFormat.fromJSON(formatProps);
58
- return { itemKey: newFormat.key };
59
- }
60
- }
61
- exports.Formats = Formats;
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.Formats = 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 Format.
15
+ */
16
+ class Formats {
17
+ constructor(_schemaEditor) {
18
+ this._schemaEditor = _schemaEditor;
19
+ }
20
+ async create(schemaKey, name, formatType, displayLabel, units) {
21
+ const schema = await this._schemaEditor.getSchema(schemaKey);
22
+ const newFormat = (await schema.createFormat(name));
23
+ if (newFormat === undefined) {
24
+ return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
25
+ }
26
+ if (units !== undefined) {
27
+ for (const unit of units) {
28
+ const unitItem = await this._schemaEditor.schemaContext.getSchemaItem(unit);
29
+ if (unitItem === undefined) {
30
+ return { errorMessage: `Failed to locate unit ${unit.name} in Schema Context.` };
31
+ }
32
+ if (unitItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit && unitItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
33
+ return { errorMessage: `${unitItem.fullName} is not of type Unit or InvertedUnit.` };
34
+ newFormat.addUnit(unitItem);
35
+ }
36
+ }
37
+ if (displayLabel)
38
+ newFormat.setDisplayLabel(displayLabel);
39
+ // TODO: Handle the setting of format traits, separators, etc....
40
+ newFormat.setFormatType(formatType);
41
+ return { itemKey: newFormat.key };
42
+ }
43
+ /**
44
+ * Creates a format through a FormatProps.
45
+ * @param schemaKey a SchemaKey of the Schema that will house the new object.
46
+ * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
47
+ */
48
+ async createFromProps(schemaKey, formatProps) {
49
+ const schema = await this._schemaEditor.getSchema(schemaKey);
50
+ if (schema === undefined)
51
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
52
+ if (formatProps.name === undefined)
53
+ return { errorMessage: `No name was supplied within props.` };
54
+ const newFormat = (await schema.createFormat(formatProps.name));
55
+ if (newFormat === undefined)
56
+ return { errorMessage: `Failed to create class ${formatProps.name} in schema ${schemaKey.toString(true)}.` };
57
+ await newFormat.fromJSON(formatProps);
58
+ return { itemKey: newFormat.key };
59
+ }
60
+ }
61
+ exports.Formats = Formats;
62
62
  //# sourceMappingURL=Formats.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiI;AAKjI;;;GAGG;AACH,MAAa,OAAO;IAClB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAsB,EAAE,YAAqB,EAAE,KAAuB;QAC5H,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAA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KAAK,SAAS;YAChC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAkB,CAAC;QACjF,IAAI,SAAS,KAAK,SAAS;YACzB,OAAO,EAAE,YAAY,EAAE,0BAA0B,WAAW,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/G,MAAM,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC;IACpC,CAAC;CACF;AAjDD,0BAiDC","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 { FormatProps, InvertedUnit, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, Unit } from \"@itwin/ecschema-metadata\";\r\nimport { FormatType } from \"@itwin/core-quantity\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableFormat } from \"./Mutable/MutableFormat\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Format.\r\n */\r\nexport class Formats {\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n public async create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n const newFormat = (await schema.createFormat(name)) as MutableFormat;\r\n if (newFormat === undefined) {\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n }\r\n\r\n if (units !== undefined) {\r\n for (const unit of units) {\r\n const unitItem = await this._schemaEditor.schemaContext.getSchemaItem<Unit | InvertedUnit>(unit);\r\n if (unitItem === undefined) {\r\n return { errorMessage: `Failed to locate unit ${unit.name} in Schema Context.` };\r\n }\r\n\r\n if (unitItem.schemaItemType !== SchemaItemType.Unit && unitItem.schemaItemType !== SchemaItemType.InvertedUnit)\r\n return { errorMessage: `${(unitItem as SchemaItem).fullName} is not of type Unit or InvertedUnit.` };\r\n newFormat.addUnit(unitItem);\r\n }\r\n }\r\n if (displayLabel)\r\n newFormat.setDisplayLabel(displayLabel);\r\n\r\n // TODO: Handle the setting of format traits, separators, etc....\r\n newFormat.setFormatType(formatType);\r\n return { itemKey: newFormat.key };\r\n }\r\n\r\n /**\r\n * Creates a format through a FormatProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, formatProps: FormatProps): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (formatProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newFormat = (await schema.createFormat(formatProps.name)) as MutableFormat;\r\n if (newFormat === undefined)\r\n return { errorMessage: `Failed to create class ${formatProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newFormat.fromJSON(formatProps);\r\n return { itemKey: newFormat.key };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiI;AAKjI;;;GAGG;AACH,MAAa,OAAO;IAClB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAA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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,WAAW,CAAC,IAAI,KAAK,SAAS;YAChC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAkB,CAAC;QACjF,IAAI,SAAS,KAAK,SAAS;YACzB,OAAO,EAAE,YAAY,EAAE,0BAA0B,WAAW,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/G,MAAM,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC;IACpC,CAAC;CACF;AAjDD,0BAiDC","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 { FormatProps, InvertedUnit, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatType } from \"@itwin/core-quantity\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableFormat } from \"./Mutable/MutableFormat\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Format.\n */\nexport class Formats {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n const newFormat = (await schema.createFormat(name)) as MutableFormat;\n if (newFormat === undefined) {\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n }\n\n if (units !== undefined) {\n for (const unit of units) {\n const unitItem = await this._schemaEditor.schemaContext.getSchemaItem<Unit | InvertedUnit>(unit);\n if (unitItem === undefined) {\n return { errorMessage: `Failed to locate unit ${unit.name} in Schema Context.` };\n }\n\n if (unitItem.schemaItemType !== SchemaItemType.Unit && unitItem.schemaItemType !== SchemaItemType.InvertedUnit)\n return { errorMessage: `${(unitItem as SchemaItem).fullName} is not of type Unit or InvertedUnit.` };\n newFormat.addUnit(unitItem);\n }\n }\n if (displayLabel)\n newFormat.setDisplayLabel(displayLabel);\n\n // TODO: Handle the setting of format traits, separators, etc....\n newFormat.setFormatType(formatType);\n return { itemKey: newFormat.key };\n }\n\n /**\n * Creates a format through a FormatProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, formatProps: FormatProps): 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 (formatProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newFormat = (await schema.createFormat(formatProps.name)) as MutableFormat;\n if (newFormat === undefined)\n return { errorMessage: `Failed to create class ${formatProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newFormat.fromJSON(formatProps);\n return { itemKey: newFormat.key };\n }\n}\n"]}
@@ -1,18 +1,18 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { InvertedUnitProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
5
- import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
- /**
7
- * @alpha
8
- * A class allowing you to create schema items of type Inverted Unit.
9
- */
10
- export declare class InvertedUnits {
11
- protected _schemaEditor: SchemaContextEditor;
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- create(schemaKey: SchemaKey, name: string, invertsUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults>;
14
- createFromProps(schemaKey: SchemaKey, invertedUnitProps: InvertedUnitProps): Promise<SchemaItemEditResults>;
15
- setInvertsUnit(invertedUnitKey: SchemaItemKey, invertsUnitKey: SchemaItemKey): Promise<void>;
16
- setUnitSystem(invertedUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey): Promise<void>;
17
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { InvertedUnitProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
5
+ import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ /**
7
+ * @alpha
8
+ * A class allowing you to create schema items of type Inverted Unit.
9
+ */
10
+ export declare class InvertedUnits {
11
+ protected _schemaEditor: SchemaContextEditor;
12
+ constructor(_schemaEditor: SchemaContextEditor);
13
+ create(schemaKey: SchemaKey, name: string, invertsUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults>;
14
+ createFromProps(schemaKey: SchemaKey, invertedUnitProps: InvertedUnitProps): Promise<SchemaItemEditResults>;
15
+ setInvertsUnit(invertedUnitKey: SchemaItemKey, invertsUnitKey: SchemaItemKey): Promise<void>;
16
+ setUnitSystem(invertedUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey): Promise<void>;
17
+ }
18
18
  //# sourceMappingURL=InvertedUnits.d.ts.map
@@ -1,83 +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
- 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;
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;
83
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;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAwB,CAAC;QAC/E,IAAI,OAAO,KAAK,SAAS;YACvB,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnG,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,UAAU,CAAO,cAAc,CAAC,CAAC;QAClE,IAAI,WAAW,KAAK,SAAS;YAC3B,OAAO,EAAE,YAAY,EAAE,yBAAyB,cAAc,CAAC,QAAQ,cAAc,MAAM,CAAC,QAA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AAC,IAAI,2CAAuB,CAAsB,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,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;YAC5B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,iBAAiB,eAAe,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEpI,IAAI,YAAY,CAAC,cAAc,KAAK,kCAAc,CAAC,YAAY;YAC7D,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,eAAe,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEvI,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAa,aAAa,CAAC,CAAC;QACnG,IAAI,UAAU,KAAK,SAAS;YAC1B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,QAAQ,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEzH,IAAI,UAAU,CAAC,cAAc,KAAK,kCAAc,CAAC,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":["/*---------------------------------------------------------------------------------------------\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)\r\n 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 const invertsUnit = await schema.lookupItem<Unit>(invertsUnitKey);\r\n if (invertsUnit === undefined)\r\n return { errorMessage: `Unable to locate unit ${invertsUnitKey.fullName} in schema ${schema.fullName}.` };\r\n\r\n if (invertsUnit.schemaItemType !== SchemaItemType.Unit)\r\n 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)\r\n return { errorMessage: `Unable to locate unit system ${unitSystemKey.fullName} in schema ${schema.fullName}.` };\r\n\r\n if (unitSystem.schemaItemType !== SchemaItemType.UnitSystem)\r\n 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)\r\n 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)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (invertedUnitProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\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 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)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);\r\n\r\n if (invertedUnit.schemaItemType !== SchemaItemType.InvertedUnit)\r\n 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)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Unit ${invertsUnitKey.fullName} not found in schema context.`);\r\n\r\n if (invertsUnit.schemaItemType !== SchemaItemType.Unit)\r\n 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)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);\r\n\r\n if (invertedUnit.schemaItemType !== SchemaItemType.InvertedUnit)\r\n 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)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Unit ${unitSystemKey.fullName} not found in schema context.`);\r\n\r\n if (unitSystem.schemaItemType !== SchemaItemType.UnitSystem)\r\n 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,CA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AAI,UAAU,KAAK,SAAS;YAC1B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,QAAQ,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEzH,IAAI,UAAU,CAAC,cAAc,KAAK,kCAAc,CAAC,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