@itwin/ecschema-editing 3.5.0-dev.65 → 3.5.0-dev.66

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 (146) hide show
  1. package/lib/cjs/Editing/Constants.d.ts +20 -20
  2. package/lib/cjs/Editing/Constants.js +60 -60
  3. package/lib/cjs/Editing/Constants.js.map +1 -1
  4. package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
  5. package/lib/cjs/Editing/CustomAttributes.js +59 -59
  6. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  7. package/lib/cjs/Editing/ECClasses.d.ts +54 -54
  8. package/lib/cjs/Editing/ECClasses.js +269 -269
  9. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  10. package/lib/cjs/Editing/Editor.d.ts +112 -112
  11. package/lib/cjs/Editing/Editor.js +166 -166
  12. package/lib/cjs/Editing/Editor.js.map +1 -1
  13. package/lib/cjs/Editing/Entities.d.ts +25 -25
  14. package/lib/cjs/Editing/Entities.js +116 -116
  15. package/lib/cjs/Editing/Entities.js.map +1 -1
  16. package/lib/cjs/Editing/Enumerations.d.ts +21 -21
  17. package/lib/cjs/Editing/Enumerations.js +66 -66
  18. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  19. package/lib/cjs/Editing/Formats.d.ts +21 -21
  20. package/lib/cjs/Editing/Formats.js +61 -61
  21. package/lib/cjs/Editing/Formats.js.map +1 -1
  22. package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
  23. package/lib/cjs/Editing/InvertedUnits.js +82 -82
  24. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  25. package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
  26. package/lib/cjs/Editing/KindOfQuantities.js +78 -78
  27. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  28. package/lib/cjs/Editing/Mixins.d.ts +22 -22
  29. package/lib/cjs/Editing/Mixins.js +84 -84
  30. package/lib/cjs/Editing/Mixins.js.map +1 -1
  31. package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
  32. package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
  33. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  34. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
  35. package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
  36. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  37. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
  38. package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
  39. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  40. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
  41. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
  42. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  43. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
  44. package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
  45. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  46. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
  47. package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
  48. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  49. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
  50. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
  51. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  52. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
  53. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
  54. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  55. package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
  56. package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
  57. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  58. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
  59. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
  60. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  61. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
  62. package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
  63. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  64. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
  65. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
  66. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  67. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
  68. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
  69. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  70. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
  71. package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
  72. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  73. package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
  74. package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
  75. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  76. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
  77. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
  78. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  79. package/lib/cjs/Editing/Phenomena.d.ts +15 -15
  80. package/lib/cjs/Editing/Phenomena.js +44 -44
  81. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  82. package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
  83. package/lib/cjs/Editing/PropertyCategories.js +51 -51
  84. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  85. package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
  86. package/lib/cjs/Editing/RelationshipClasses.js +68 -68
  87. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  88. package/lib/cjs/Editing/Structs.d.ts +19 -19
  89. package/lib/cjs/Editing/Structs.js +57 -57
  90. package/lib/cjs/Editing/Structs.js.map +1 -1
  91. package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
  92. package/lib/cjs/Editing/UnitSystems.js +41 -41
  93. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  94. package/lib/cjs/Editing/Units.d.ts +15 -15
  95. package/lib/cjs/Editing/Units.js +58 -58
  96. package/lib/cjs/Editing/Units.js.map +1 -1
  97. package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
  98. package/lib/cjs/Validation/Diagnostic.js +310 -310
  99. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  100. package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
  101. package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
  102. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  103. package/lib/cjs/Validation/ECRules.d.ts +448 -448
  104. package/lib/cjs/Validation/ECRules.js +593 -593
  105. package/lib/cjs/Validation/ECRules.js.map +1 -1
  106. package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
  107. package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
  108. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  109. package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -59
  110. package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
  111. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  112. package/lib/cjs/Validation/Rules.d.ts +64 -64
  113. package/lib/cjs/Validation/Rules.js +9 -9
  114. package/lib/cjs/Validation/Rules.js.map +1 -1
  115. package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
  116. package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
  117. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  118. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
  119. package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
  120. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  121. package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
  122. package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
  123. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  124. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
  125. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
  126. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  127. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
  128. package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
  129. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  130. package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
  131. package/lib/cjs/Validation/SchemaComparer.js +666 -666
  132. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  133. package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
  134. package/lib/cjs/Validation/SchemaValidater.js +61 -61
  135. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  136. package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
  137. package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -492
  138. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  139. package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
  140. package/lib/cjs/Validation/SchemaWalker.js +51 -51
  141. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  142. package/lib/cjs/ecschema-editing.d.ts +33 -33
  143. package/lib/cjs/ecschema-editing.js +54 -54
  144. package/lib/cjs/ecschema-editing.js.map +1 -1
  145. package/package.json +10 -10
  146. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1,58 +1,58 @@
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.Structs = void 0;
11
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
- const ECClasses_1 = require("./ECClasses");
13
- /**
14
- * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.
15
- */
16
- class Structs extends ECClasses_1.ECClasses {
17
- constructor(_schemaEditor) {
18
- super(_schemaEditor);
19
- }
20
- async create(schemaKey, name, displayLabel, baseClass) {
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 newClass = (await schema.createStructClass(name));
25
- if (newClass === undefined)
26
- return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
27
- if (baseClass !== undefined) {
28
- const baseClassItem = await schema.lookupItem(baseClass);
29
- if (baseClassItem === undefined)
30
- return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };
31
- if (baseClassItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.StructClass)
32
- return { errorMessage: `${baseClassItem.fullName} is not of type Struct Class.` };
33
- newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClass, async () => baseClassItem);
34
- }
35
- if (displayLabel)
36
- newClass.setDisplayLabel(displayLabel);
37
- return { itemKey: newClass.key };
38
- }
39
- /**
40
- * Creates a StructClass through a StructClassProps.
41
- * @param schemaKey a SchemaKey of the Schema that will house the new object.
42
- * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.
43
- */
44
- async createFromProps(schemaKey, structProps) {
45
- const schema = await this._schemaEditor.getSchema(schemaKey);
46
- if (schema === undefined)
47
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
48
- if (structProps.name === undefined)
49
- return { errorMessage: `No name was supplied within props.` };
50
- const newClass = (await schema.createStructClass(structProps.name));
51
- if (newClass === undefined)
52
- return { errorMessage: `Failed to create class ${structProps.name} in schema ${schemaKey.toString(true)}.` };
53
- await newClass.fromJSON(structProps);
54
- return { itemKey: newClass.key };
55
- }
56
- }
57
- exports.Structs = Structs;
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.Structs = void 0;
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ const ECClasses_1 = require("./ECClasses");
13
+ /**
14
+ * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.
15
+ */
16
+ class Structs extends ECClasses_1.ECClasses {
17
+ constructor(_schemaEditor) {
18
+ super(_schemaEditor);
19
+ }
20
+ async create(schemaKey, name, displayLabel, baseClass) {
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 newClass = (await schema.createStructClass(name));
25
+ if (newClass === undefined)
26
+ return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
27
+ if (baseClass !== undefined) {
28
+ const baseClassItem = await schema.lookupItem(baseClass);
29
+ if (baseClassItem === undefined)
30
+ return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };
31
+ if (baseClassItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.StructClass)
32
+ return { errorMessage: `${baseClassItem.fullName} is not of type Struct Class.` };
33
+ newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClass, async () => baseClassItem);
34
+ }
35
+ if (displayLabel)
36
+ newClass.setDisplayLabel(displayLabel);
37
+ return { itemKey: newClass.key };
38
+ }
39
+ /**
40
+ * Creates a StructClass through a StructClassProps.
41
+ * @param schemaKey a SchemaKey of the Schema that will house the new object.
42
+ * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.
43
+ */
44
+ async createFromProps(schemaKey, structProps) {
45
+ const schema = await this._schemaEditor.getSchema(schemaKey);
46
+ if (schema === undefined)
47
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
48
+ if (structProps.name === undefined)
49
+ return { errorMessage: `No name was supplied within props.` };
50
+ const newClass = (await schema.createStructClass(structProps.name));
51
+ if (newClass === undefined)
52
+ return { errorMessage: `Failed to create class ${structProps.name} in schema ${schemaKey.toString(true)}.` };
53
+ await newClass.fromJSON(structProps);
54
+ return { itemKey: newClass.key };
55
+ }
56
+ }
57
+ exports.Structs = Structs;
58
58
  //# sourceMappingURL=Structs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAqJ;AAErJ,2CAAwC;AAGxC;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,SAAyB;QACtG,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,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAuB,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C,CAAiB,CAAC;QACpF,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,WAAW,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/G,MAAM,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AAnDD,0BAmDC","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 { DelayedPromiseWithProps, ECClass, SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableClass, MutableStructClass } from \"./Mutable/MutableClass\";\r\n\r\n/**\r\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\r\n */\r\nexport class Structs extends ECClasses {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClass?: SchemaItemKey): 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 newClass = (await schema.createStructClass(name)) as MutableStructClass;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n if (baseClass !== undefined) {\r\n const baseClassItem = await schema.lookupItem<StructClass>(baseClass);\r\n if (baseClassItem === undefined)\r\n return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };\r\n\r\n if (baseClassItem.schemaItemType !== SchemaItemType.StructClass)\r\n return { errorMessage: `${baseClassItem.fullName} is not of type Struct Class.` };\r\n\r\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClass, async () => baseClassItem);\r\n }\r\n\r\n if (displayLabel)\r\n newClass.setDisplayLabel(displayLabel);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n /**\r\n * Creates a StructClass through a StructClassProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): 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 (structProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newClass = (await schema.createStructClass(structProps.name)) as MutableClass;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${structProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newClass.fromJSON(structProps);\r\n return { itemKey: newClass.key };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAqJ;AAErJ,2CAAwC;AAGxC;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,SAAyB;QACtG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QA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CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS;YAChC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAiB,CAAC;QACpF,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,WAAW,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/G,MAAM,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AAnDD,0BAmDC","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 { DelayedPromiseWithProps, ECClass, SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableClass, MutableStructClass } from \"./Mutable/MutableClass\";\n\n/**\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\n */\nexport class Structs extends ECClasses {\n public constructor(_schemaEditor: SchemaContextEditor) {\n super(_schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClass?: SchemaItemKey): 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 newClass = (await schema.createStructClass(name)) as MutableStructClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n if (baseClass !== undefined) {\n const baseClassItem = await schema.lookupItem<StructClass>(baseClass);\n if (baseClassItem === undefined)\n return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };\n\n if (baseClassItem.schemaItemType !== SchemaItemType.StructClass)\n return { errorMessage: `${baseClassItem.fullName} is not of type Struct Class.` };\n\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClass, async () => baseClassItem);\n }\n\n if (displayLabel)\n newClass.setDisplayLabel(displayLabel);\n\n return { itemKey: newClass.key };\n }\n\n /**\n * Creates a StructClass through a StructClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): 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 (structProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newClass = (await schema.createStructClass(structProps.name)) as MutableClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${structProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newClass.fromJSON(structProps);\n return { itemKey: newClass.key };\n }\n}\n"]}
@@ -1,16 +1,16 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { SchemaKey, UnitSystemProps } from "@itwin/ecschema-metadata";
5
- import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
- /**
7
- * @alpha
8
- * A class allowing you to create schema items of type UnitSystems.
9
- */
10
- export declare class UnitSystems {
11
- protected _schemaEditor: SchemaContextEditor;
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemEditResults>;
14
- createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemEditResults>;
15
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { SchemaKey, UnitSystemProps } from "@itwin/ecschema-metadata";
5
+ import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ /**
7
+ * @alpha
8
+ * A class allowing you to create schema items of type UnitSystems.
9
+ */
10
+ export declare class UnitSystems {
11
+ protected _schemaEditor: SchemaContextEditor;
12
+ constructor(_schemaEditor: SchemaContextEditor);
13
+ create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemEditResults>;
14
+ createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemEditResults>;
15
+ }
16
16
  //# sourceMappingURL=UnitSystems.d.ts.map
@@ -1,42 +1,42 @@
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.UnitSystems = void 0;
11
- /**
12
- * @alpha
13
- * A class allowing you to create schema items of type UnitSystems.
14
- */
15
- class UnitSystems {
16
- constructor(_schemaEditor) {
17
- this._schemaEditor = _schemaEditor;
18
- }
19
- async create(schemaKey, name, displayLabel) {
20
- const schema = await this._schemaEditor.getSchema(schemaKey);
21
- if (schema === undefined)
22
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
23
- const newUnitSystem = (await schema.createUnitSystem(name));
24
- if (displayLabel)
25
- newUnitSystem.setDisplayLabel(displayLabel);
26
- return { itemKey: newUnitSystem.key };
27
- }
28
- async createFromProps(schemaKey, unitSystemProps) {
29
- const schema = await this._schemaEditor.getSchema(schemaKey);
30
- if (schema === undefined)
31
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
32
- if (unitSystemProps.name === undefined)
33
- return { errorMessage: `No name was supplied within props.` };
34
- const newUnitSystem = (await schema.createUnitSystem(unitSystemProps.name));
35
- if (newUnitSystem === undefined)
36
- return { errorMessage: `Failed to create class ${unitSystemProps.name} in schema ${schemaKey.toString(true)}.` };
37
- await newUnitSystem.fromJSON(unitSystemProps);
38
- return { itemKey: newUnitSystem.key };
39
- }
40
- }
41
- exports.UnitSystems = UnitSystems;
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.UnitSystems = void 0;
11
+ /**
12
+ * @alpha
13
+ * A class allowing you to create schema items of type UnitSystems.
14
+ */
15
+ class UnitSystems {
16
+ constructor(_schemaEditor) {
17
+ this._schemaEditor = _schemaEditor;
18
+ }
19
+ async create(schemaKey, name, displayLabel) {
20
+ const schema = await this._schemaEditor.getSchema(schemaKey);
21
+ if (schema === undefined)
22
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
23
+ const newUnitSystem = (await schema.createUnitSystem(name));
24
+ if (displayLabel)
25
+ newUnitSystem.setDisplayLabel(displayLabel);
26
+ return { itemKey: newUnitSystem.key };
27
+ }
28
+ async createFromProps(schemaKey, unitSystemProps) {
29
+ const schema = await this._schemaEditor.getSchema(schemaKey);
30
+ if (schema === undefined)
31
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
32
+ if (unitSystemProps.name === undefined)
33
+ return { errorMessage: `No name was supplied within props.` };
34
+ const newUnitSystem = (await schema.createUnitSystem(unitSystemProps.name));
35
+ if (newUnitSystem === undefined)
36
+ return { errorMessage: `Failed to create class ${unitSystemProps.name} in schema ${schemaKey.toString(true)}.` };
37
+ await newUnitSystem.fromJSON(unitSystemProps);
38
+ return { itemKey: newUnitSystem.key };
39
+ }
40
+ }
41
+ exports.UnitSystems = UnitSystems;
42
42
  //# sourceMappingURL=UnitSystems.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAC3E,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,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAsB,CAAC;QACjF,IAAI,YAAY;YACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAE9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,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,eAAe,CAAC,IAAI,KAAK,SAAS;YACpC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAsB,CAAC;QACjG,IAAI,aAAa,KAAK,SAAS;YAC7B,OAAO,EAAE,YAAY,EAAE,0BAA0B,eAAe,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnH,MAAM,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;CACF;AA7BD,kCA6BC","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 { SchemaKey, UnitSystemProps } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type UnitSystems.\r\n */\r\nexport class UnitSystems {\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n public async create(schemaKey: SchemaKey, name: string, 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 newUnitSystem = (await schema.createUnitSystem(name)) as MutableUnitSystem;\r\n if (displayLabel)\r\n newUnitSystem.setDisplayLabel(displayLabel);\r\n\r\n return { itemKey: newUnitSystem.key };\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): 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 (unitSystemProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newUnitSystem = (await schema.createUnitSystem(unitSystemProps.name)) as MutableUnitSystem;\r\n if (newUnitSystem === undefined)\r\n return { errorMessage: `Failed to create class ${unitSystemProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newUnitSystem.fromJSON(unitSystemProps);\r\n return { itemKey: newUnitSystem.key };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAC3E,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,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAsB,CAAC;QACjF,IAAI,YAAY;YACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAE9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,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,eAAe,CAAC,IAAI,KAAK,SAAS;YACpC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAsB,CAAC;QACjG,IAAI,aAAa,KAAK,SAAS;YAC7B,OAAO,EAAE,YAAY,EAAE,0BAA0B,eAAe,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnH,MAAM,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;CACF;AA7BD,kCA6BC","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 { SchemaKey, UnitSystemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type UnitSystems.\n */\nexport class UnitSystems {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async create(schemaKey: SchemaKey, name: string, 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 newUnitSystem = (await schema.createUnitSystem(name)) as MutableUnitSystem;\n if (displayLabel)\n newUnitSystem.setDisplayLabel(displayLabel);\n\n return { itemKey: newUnitSystem.key };\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): 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 (unitSystemProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newUnitSystem = (await schema.createUnitSystem(unitSystemProps.name)) as MutableUnitSystem;\n if (newUnitSystem === undefined)\n return { errorMessage: `Failed to create class ${unitSystemProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newUnitSystem.fromJSON(unitSystemProps);\n return { itemKey: newUnitSystem.key };\n }\n}\n"]}
@@ -1,16 +1,16 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { SchemaItemKey, SchemaKey, UnitProps } from "@itwin/ecschema-metadata";
5
- import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
- /**
7
- * @alpha
8
- * A class allowing you to create schema items of type Unit.
9
- */
10
- export declare class Units {
11
- protected _schemaEditor: SchemaContextEditor;
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults>;
14
- createFromProps(schemaKey: SchemaKey, unitProps: UnitProps): Promise<SchemaItemEditResults>;
15
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { SchemaItemKey, SchemaKey, UnitProps } from "@itwin/ecschema-metadata";
5
+ import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ /**
7
+ * @alpha
8
+ * A class allowing you to create schema items of type Unit.
9
+ */
10
+ export declare class Units {
11
+ protected _schemaEditor: SchemaContextEditor;
12
+ constructor(_schemaEditor: SchemaContextEditor);
13
+ create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults>;
14
+ createFromProps(schemaKey: SchemaKey, unitProps: UnitProps): Promise<SchemaItemEditResults>;
15
+ }
16
16
  //# sourceMappingURL=Units.d.ts.map
@@ -1,59 +1,59 @@
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.Units = 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 Unit.
15
- */
16
- class Units {
17
- // TODO: Add more setters for all attributes.
18
- constructor(_schemaEditor) {
19
- this._schemaEditor = _schemaEditor;
20
- }
21
- async create(schemaKey, name, definition, phenomenon, unitSystem, displayLabel) {
22
- const schema = await this._schemaEditor.getSchema(schemaKey);
23
- if (schema === undefined)
24
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
25
- const newUnit = (await schema.createUnit(name));
26
- if (newUnit === undefined)
27
- return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
28
- const phenomenonItem = await schema.lookupItem(phenomenon);
29
- if (phenomenonItem === undefined)
30
- return { errorMessage: `Unable to locate phenomenon ${phenomenon.fullName} in schema ${schema.fullName}.` };
31
- if (phenomenonItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.Phenomenon)
32
- return { errorMessage: `${phenomenon.fullName} is not of type Phenomenon.` };
33
- await newUnit.setPhenomenon(new ecschema_metadata_1.DelayedPromiseWithProps(phenomenon, async () => phenomenonItem));
34
- const unitSystemItem = await schema.lookupItem(unitSystem);
35
- if (unitSystemItem === undefined)
36
- return { errorMessage: `Unable to locate unit system ${unitSystem.fullName} in schema ${schema.fullName}.` };
37
- if (unitSystemItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
38
- return { errorMessage: `${unitSystem.fullName} is not of type UnitSystem.` };
39
- await newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystem, async () => unitSystemItem));
40
- await newUnit.setDefinition(definition);
41
- if (displayLabel)
42
- newUnit.setDisplayLabel(displayLabel);
43
- return { itemKey: newUnit.key };
44
- }
45
- async createFromProps(schemaKey, unitProps) {
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 (unitProps.name === undefined)
50
- return { errorMessage: `No name was supplied within props.` };
51
- const newUnit = (await schema.createUnit(unitProps.name));
52
- if (newUnit === undefined)
53
- return { errorMessage: `Failed to create class ${unitProps.name} in schema ${schemaKey.toString(true)}.` };
54
- await newUnit.fromJSON(unitProps);
55
- return { itemKey: newUnit.key };
56
- }
57
- }
58
- exports.Units = Units;
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.Units = 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 Unit.
15
+ */
16
+ class Units {
17
+ // TODO: Add more setters for all attributes.
18
+ constructor(_schemaEditor) {
19
+ this._schemaEditor = _schemaEditor;
20
+ }
21
+ async create(schemaKey, name, definition, phenomenon, unitSystem, displayLabel) {
22
+ const schema = await this._schemaEditor.getSchema(schemaKey);
23
+ if (schema === undefined)
24
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
25
+ const newUnit = (await schema.createUnit(name));
26
+ if (newUnit === undefined)
27
+ return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
28
+ const phenomenonItem = await schema.lookupItem(phenomenon);
29
+ if (phenomenonItem === undefined)
30
+ return { errorMessage: `Unable to locate phenomenon ${phenomenon.fullName} in schema ${schema.fullName}.` };
31
+ if (phenomenonItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.Phenomenon)
32
+ return { errorMessage: `${phenomenon.fullName} is not of type Phenomenon.` };
33
+ await newUnit.setPhenomenon(new ecschema_metadata_1.DelayedPromiseWithProps(phenomenon, async () => phenomenonItem));
34
+ const unitSystemItem = await schema.lookupItem(unitSystem);
35
+ if (unitSystemItem === undefined)
36
+ return { errorMessage: `Unable to locate unit system ${unitSystem.fullName} in schema ${schema.fullName}.` };
37
+ if (unitSystemItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
38
+ return { errorMessage: `${unitSystem.fullName} is not of type UnitSystem.` };
39
+ await newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystem, async () => unitSystemItem));
40
+ await newUnit.setDefinition(definition);
41
+ if (displayLabel)
42
+ newUnit.setDisplayLabel(displayLabel);
43
+ return { itemKey: newUnit.key };
44
+ }
45
+ async createFromProps(schemaKey, unitProps) {
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 (unitProps.name === undefined)
50
+ return { errorMessage: `No name was supplied within props.` };
51
+ const newUnit = (await schema.createUnit(unitProps.name));
52
+ if (newUnit === undefined)
53
+ return { errorMessage: `Failed to create class ${unitProps.name} in schema ${schemaKey.toString(true)}.` };
54
+ await newUnit.fromJSON(unitProps);
55
+ return { itemKey: newUnit.key };
56
+ }
57
+ }
58
+ exports.Units = Units;
59
59
  //# sourceMappingURL=Units.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAgJ;AAIhJ;;;GAGG;AACH,MAAa,KAAK;IAChB,6CAA6C;IAC7C,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa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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 { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaKey, UnitProps, UnitSystem } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Unit.\r\n */\r\nexport class Units {\r\n // TODO: Add more setters for all attributes.\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: 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.createUnit(name)) as MutableUnit;\r\n if (newUnit === undefined)\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n const phenomenonItem = await schema.lookupItem<Phenomenon>(phenomenon);\r\n if (phenomenonItem === undefined)\r\n return { errorMessage: `Unable to locate phenomenon ${phenomenon.fullName} in schema ${schema.fullName}.` };\r\n\r\n if (phenomenonItem.schemaItemType !== SchemaItemType.Phenomenon)\r\n return { errorMessage: `${phenomenon.fullName} is not of type Phenomenon.` };\r\n\r\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\r\n\r\n const unitSystemItem = await schema.lookupItem<UnitSystem>(unitSystem);\r\n if (unitSystemItem === undefined)\r\n return { errorMessage: `Unable to locate unit system ${unitSystem.fullName} in schema ${schema.fullName}.` };\r\n\r\n if (unitSystemItem.schemaItemType !== SchemaItemType.UnitSystem)\r\n return { errorMessage: `${unitSystem.fullName} is not of type UnitSystem.` };\r\n\r\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\r\n\r\n await newUnit.setDefinition(definition);\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, unitProps: UnitProps): 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 (unitProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newUnit = (await schema.createUnit(unitProps.name));\r\n if (newUnit === undefined)\r\n return { errorMessage: `Failed to create class ${unitProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newUnit.fromJSON(unitProps);\r\n return { itemKey: newUnit.key };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAgJ;AAIhJ;;;GAGG;AACH,MAAa,KAAK;IAChB,6CAA6C;IAC7C,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAyB,EAAE,UAAyB,EAAE,YAAqB;QACrJ,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,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ExC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAAoB;QACrE,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,SAAS,CAAC,IAAI,KAAK,SAAS;YAC9B,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,IAAI,OAAO,KAAK,SAAS;YACvB,OAAO,EAAE,YAAY,EAAE,0BAA0B,SAAS,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7G,MAAM,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAClC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;CACF;AAtDD,sBAsDC","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 { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaKey, UnitProps, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Unit.\n */\nexport class Units {\n // TODO: Add more setters for all attributes.\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: 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.createUnit(name)) as MutableUnit;\n if (newUnit === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n const phenomenonItem = await schema.lookupItem<Phenomenon>(phenomenon);\n if (phenomenonItem === undefined)\n return { errorMessage: `Unable to locate phenomenon ${phenomenon.fullName} in schema ${schema.fullName}.` };\n\n if (phenomenonItem.schemaItemType !== SchemaItemType.Phenomenon)\n return { errorMessage: `${phenomenon.fullName} is not of type Phenomenon.` };\n\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\n\n const unitSystemItem = await schema.lookupItem<UnitSystem>(unitSystem);\n if (unitSystemItem === undefined)\n return { errorMessage: `Unable to locate unit system ${unitSystem.fullName} in schema ${schema.fullName}.` };\n\n if (unitSystemItem.schemaItemType !== SchemaItemType.UnitSystem)\n return { errorMessage: `${unitSystem.fullName} is not of type UnitSystem.` };\n\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\n\n await newUnit.setDefinition(definition);\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return { itemKey: newUnit.key };\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitProps: UnitProps): 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 (unitProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newUnit = (await schema.createUnit(unitProps.name));\n if (newUnit === undefined)\n return { errorMessage: `Failed to create class ${unitProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newUnit.fromJSON(unitProps);\n return { itemKey: newUnit.key };\n }\n}\n"]}