@itwin/ecschema-editing 4.0.0-dev.52 → 4.0.0-dev.55

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 (102) 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/CustomAttributes.d.ts +20 -20
  4. package/lib/cjs/Editing/CustomAttributes.js +59 -59
  5. package/lib/cjs/Editing/ECClasses.d.ts +54 -54
  6. package/lib/cjs/Editing/ECClasses.js +269 -269
  7. package/lib/cjs/Editing/Editor.d.ts +112 -112
  8. package/lib/cjs/Editing/Editor.js +166 -166
  9. package/lib/cjs/Editing/Entities.d.ts +25 -25
  10. package/lib/cjs/Editing/Entities.js +116 -116
  11. package/lib/cjs/Editing/Enumerations.d.ts +21 -21
  12. package/lib/cjs/Editing/Enumerations.js +66 -66
  13. package/lib/cjs/Editing/Formats.d.ts +21 -21
  14. package/lib/cjs/Editing/Formats.js +61 -61
  15. package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
  16. package/lib/cjs/Editing/InvertedUnits.js +82 -82
  17. package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
  18. package/lib/cjs/Editing/KindOfQuantities.js +78 -78
  19. package/lib/cjs/Editing/Mixins.d.ts +22 -22
  20. package/lib/cjs/Editing/Mixins.js +84 -84
  21. package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
  22. package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
  23. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
  24. package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
  25. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
  26. package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
  27. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
  28. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
  29. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
  30. package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
  31. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
  32. package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
  33. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
  34. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
  35. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
  36. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
  37. package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
  38. package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
  39. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
  40. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
  41. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
  42. package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
  43. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
  44. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
  45. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
  46. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
  47. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
  48. package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
  49. package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
  50. package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
  51. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
  52. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
  53. package/lib/cjs/Editing/Phenomena.d.ts +15 -15
  54. package/lib/cjs/Editing/Phenomena.js +44 -44
  55. package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
  56. package/lib/cjs/Editing/PropertyCategories.js +51 -51
  57. package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
  58. package/lib/cjs/Editing/RelationshipClasses.js +68 -68
  59. package/lib/cjs/Editing/Structs.d.ts +19 -19
  60. package/lib/cjs/Editing/Structs.js +57 -57
  61. package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
  62. package/lib/cjs/Editing/UnitSystems.js +41 -41
  63. package/lib/cjs/Editing/Units.d.ts +15 -15
  64. package/lib/cjs/Editing/Units.js +58 -58
  65. package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
  66. package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
  67. package/lib/cjs/Validation/Diagnostic.js +310 -310
  68. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  69. package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
  70. package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
  71. package/lib/cjs/Validation/ECRules.d.ts +448 -448
  72. package/lib/cjs/Validation/ECRules.js +593 -593
  73. package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
  74. package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
  75. package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -59
  76. package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
  77. package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
  78. package/lib/cjs/Validation/Rules.d.ts +64 -64
  79. package/lib/cjs/Validation/Rules.d.ts.map +1 -1
  80. package/lib/cjs/Validation/Rules.js +9 -9
  81. package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
  82. package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
  83. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
  84. package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
  85. package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
  86. package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
  87. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
  88. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
  89. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
  90. package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
  91. package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
  92. package/lib/cjs/Validation/SchemaComparer.js +666 -666
  93. package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
  94. package/lib/cjs/Validation/SchemaValidater.js +61 -61
  95. package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
  96. package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -492
  97. package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
  98. package/lib/cjs/Validation/SchemaWalker.js +51 -51
  99. package/lib/cjs/ecschema-editing.d.ts +33 -33
  100. package/lib/cjs/ecschema-editing.js +58 -54
  101. package/lib/cjs/ecschema-editing.js.map +1 -1
  102. package/package.json +11 -11
@@ -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,29 +1,29 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { InvertedUnit, KindOfQuantityProps, OverrideFormat, SchemaItemKey, SchemaKey, Unit } from "@itwin/ecschema-metadata";
5
- import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
- /**
7
- * @alpha
8
- * A class allowing you to create schema items of type KindOfQuantity.
9
- */
10
- export declare class KindOfQuantities {
11
- protected _schemaEditor: SchemaContextEditor;
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemEditResults>;
14
- /**
15
- *
16
- * @param koqKey A schemaItemKey of the editing KindOfQuantity.
17
- * @param format A schemaItemKey of a Format.
18
- * @param isDefault .is set to false when not explicitly passed.
19
- */
20
- addPresentationFormat(koqKey: SchemaItemKey, format: SchemaItemKey, isDefault?: boolean): Promise<void>;
21
- addPresentationOverrideFormat(koqKey: SchemaItemKey, overrideFormat: OverrideFormat, isDefault?: boolean): Promise<void>;
22
- /**
23
- * @param koqKey A schemaItemKey of the editing KindOfQuantity.
24
- * @param parent A SchemaItemKey of the parent Format.
25
- * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
26
- */
27
- createFormatOverride(koqKey: SchemaItemKey, parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat>;
28
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { InvertedUnit, KindOfQuantityProps, OverrideFormat, SchemaItemKey, SchemaKey, Unit } from "@itwin/ecschema-metadata";
5
+ import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ /**
7
+ * @alpha
8
+ * A class allowing you to create schema items of type KindOfQuantity.
9
+ */
10
+ export declare class KindOfQuantities {
11
+ protected _schemaEditor: SchemaContextEditor;
12
+ constructor(_schemaEditor: SchemaContextEditor);
13
+ createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemEditResults>;
14
+ /**
15
+ *
16
+ * @param koqKey A schemaItemKey of the editing KindOfQuantity.
17
+ * @param format A schemaItemKey of a Format.
18
+ * @param isDefault .is set to false when not explicitly passed.
19
+ */
20
+ addPresentationFormat(koqKey: SchemaItemKey, format: SchemaItemKey, isDefault?: boolean): Promise<void>;
21
+ addPresentationOverrideFormat(koqKey: SchemaItemKey, overrideFormat: OverrideFormat, isDefault?: boolean): Promise<void>;
22
+ /**
23
+ * @param koqKey A schemaItemKey of the editing KindOfQuantity.
24
+ * @param parent A SchemaItemKey of the parent Format.
25
+ * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
26
+ */
27
+ createFormatOverride(koqKey: SchemaItemKey, parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat>;
28
+ }
29
29
  //# sourceMappingURL=KindOfQuantities.d.ts.map
@@ -1,79 +1,79 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Editing
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.KindOfQuantities = void 0;
11
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
- /**
13
- * @alpha
14
- * A class allowing you to create schema items of type KindOfQuantity.
15
- */
16
- class KindOfQuantities {
17
- constructor(_schemaEditor) {
18
- this._schemaEditor = _schemaEditor;
19
- }
20
- async createFromProps(schemaKey, koqProps) {
21
- const schema = await this._schemaEditor.getSchema(schemaKey);
22
- if (schema === undefined)
23
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
24
- if (koqProps.name === undefined)
25
- return { errorMessage: `No name was supplied within props.` };
26
- const newKoQ = (await schema.createKindOfQuantity(koqProps.name));
27
- if (newKoQ === undefined)
28
- return { errorMessage: `Failed to create class ${koqProps.name} in schema ${schemaKey.toString(true)}.` };
29
- await newKoQ.fromJSON(koqProps);
30
- return { itemKey: newKoQ.key };
31
- }
32
- /**
33
- *
34
- * @param koqKey A schemaItemKey of the editing KindOfQuantity.
35
- * @param format A schemaItemKey of a Format.
36
- * @param isDefault .is set to false when not explicitly passed.
37
- */
38
- async addPresentationFormat(koqKey, format, isDefault = false) {
39
- const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
40
- if (kindOfQuantity === undefined)
41
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
42
- if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
43
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
44
- const presentationFormat = await (this._schemaEditor.schemaContext.getSchemaItem(format));
45
- if (undefined === presentationFormat)
46
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${format.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
47
- if (presentationFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
48
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${presentationFormat.fullName} to be of type Format.`);
49
- kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);
50
- }
51
- async addPresentationOverrideFormat(koqKey, overrideFormat, isDefault = false) {
52
- const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
53
- if (kindOfQuantity === undefined)
54
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
55
- if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
56
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
57
- kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);
58
- }
59
- /**
60
- * @param koqKey A schemaItemKey of the editing KindOfQuantity.
61
- * @param parent A SchemaItemKey of the parent Format.
62
- * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
63
- */
64
- async createFormatOverride(koqKey, parent, precision, unitLabelOverrides) {
65
- const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
66
- if (kindOfQuantity === undefined)
67
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
68
- if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
69
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
70
- const parentFormat = await (this._schemaEditor.schemaContext.getSchemaItem(parent));
71
- if (undefined === parentFormat)
72
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${parent.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
73
- if (parentFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
74
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${parentFormat.fullName} to be of type Format.`);
75
- return new ecschema_metadata_1.OverrideFormat(parentFormat, precision, unitLabelOverrides);
76
- }
77
- }
78
- exports.KindOfQuantities = KindOfQuantities;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Editing
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.KindOfQuantities = void 0;
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ /**
13
+ * @alpha
14
+ * A class allowing you to create schema items of type KindOfQuantity.
15
+ */
16
+ class KindOfQuantities {
17
+ constructor(_schemaEditor) {
18
+ this._schemaEditor = _schemaEditor;
19
+ }
20
+ async createFromProps(schemaKey, koqProps) {
21
+ const schema = await this._schemaEditor.getSchema(schemaKey);
22
+ if (schema === undefined)
23
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
24
+ if (koqProps.name === undefined)
25
+ return { errorMessage: `No name was supplied within props.` };
26
+ const newKoQ = (await schema.createKindOfQuantity(koqProps.name));
27
+ if (newKoQ === undefined)
28
+ return { errorMessage: `Failed to create class ${koqProps.name} in schema ${schemaKey.toString(true)}.` };
29
+ await newKoQ.fromJSON(koqProps);
30
+ return { itemKey: newKoQ.key };
31
+ }
32
+ /**
33
+ *
34
+ * @param koqKey A schemaItemKey of the editing KindOfQuantity.
35
+ * @param format A schemaItemKey of a Format.
36
+ * @param isDefault .is set to false when not explicitly passed.
37
+ */
38
+ async addPresentationFormat(koqKey, format, isDefault = false) {
39
+ const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
40
+ if (kindOfQuantity === undefined)
41
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
42
+ if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
43
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
44
+ const presentationFormat = await (this._schemaEditor.schemaContext.getSchemaItem(format));
45
+ if (undefined === presentationFormat)
46
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${format.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
47
+ if (presentationFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
48
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${presentationFormat.fullName} to be of type Format.`);
49
+ kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);
50
+ }
51
+ async addPresentationOverrideFormat(koqKey, overrideFormat, isDefault = false) {
52
+ const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
53
+ if (kindOfQuantity === undefined)
54
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
55
+ if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
56
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
57
+ kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);
58
+ }
59
+ /**
60
+ * @param koqKey A schemaItemKey of the editing KindOfQuantity.
61
+ * @param parent A SchemaItemKey of the parent Format.
62
+ * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
63
+ */
64
+ async createFormatOverride(koqKey, parent, precision, unitLabelOverrides) {
65
+ const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
66
+ if (kindOfQuantity === undefined)
67
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
68
+ if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
69
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
70
+ const parentFormat = await (this._schemaEditor.schemaContext.getSchemaItem(parent));
71
+ if (undefined === parentFormat)
72
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${parent.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
73
+ if (parentFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
74
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${parentFormat.fullName} to be of type Format.`);
75
+ return new ecschema_metadata_1.OverrideFormat(parentFormat, precision, unitLabelOverrides);
76
+ }
77
+ }
78
+ exports.KindOfQuantities = KindOfQuantities;
79
79
  //# sourceMappingURL=KindOfQuantities.js.map
@@ -1,23 +1,23 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { MixinProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
5
- import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
- import { ECClasses } from "./ECClasses";
7
- /**
8
- * @alpha
9
- * A class extending ECClasses allowing you to create schema items of type Mixin.
10
- */
11
- export declare class Mixins extends ECClasses {
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- create(schemaKey: SchemaKey, name: string, appliesTo: SchemaItemKey, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
14
- /**
15
- * Creates a MixinClass through a MixinProps.
16
- * @param schemaKey a SchemaKey of the Schema that will house the new object.
17
- * @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.
18
- */
19
- createFromProps(schemaKey: SchemaKey, mixinProps: MixinProps): Promise<SchemaItemEditResults>;
20
- addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void>;
21
- createNavigationProperty(mixinKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
22
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { MixinProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
5
+ import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ import { ECClasses } from "./ECClasses";
7
+ /**
8
+ * @alpha
9
+ * A class extending ECClasses allowing you to create schema items of type Mixin.
10
+ */
11
+ export declare class Mixins extends ECClasses {
12
+ constructor(_schemaEditor: SchemaContextEditor);
13
+ create(schemaKey: SchemaKey, name: string, appliesTo: SchemaItemKey, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
14
+ /**
15
+ * Creates a MixinClass through a MixinProps.
16
+ * @param schemaKey a SchemaKey of the Schema that will house the new object.
17
+ * @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.
18
+ */
19
+ createFromProps(schemaKey: SchemaKey, mixinProps: MixinProps): Promise<SchemaItemEditResults>;
20
+ addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void>;
21
+ createNavigationProperty(mixinKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
22
+ }
23
23
  //# sourceMappingURL=Mixins.d.ts.map
@@ -1,85 +1,85 @@
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.Mixins = void 0;
11
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
- const ECClasses_1 = require("./ECClasses");
13
- /**
14
- * @alpha
15
- * A class extending ECClasses allowing you to create schema items of type Mixin.
16
- */
17
- class Mixins extends ECClasses_1.ECClasses {
18
- constructor(_schemaEditor) {
19
- super(_schemaEditor);
20
- }
21
- async create(schemaKey, name, appliesTo, displayLabel, baseClass) {
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 newClass = (await schema.createMixinClass(name));
26
- if (newClass === undefined)
27
- return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
28
- if (baseClass !== undefined) {
29
- const baseClassItem = await schema.lookupItem(baseClass);
30
- if (baseClassItem === undefined)
31
- return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };
32
- if (baseClassItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.Mixin)
33
- return { errorMessage: `${baseClassItem.fullName} is not of type Mixin.` };
34
- newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClass, async () => baseClassItem);
35
- }
36
- const newAppliesTo = (await this._schemaEditor.schemaContext.getSchemaItem(appliesTo));
37
- if (newAppliesTo === undefined || newAppliesTo.schemaItemType !== ecschema_metadata_1.SchemaItemType.EntityClass)
38
- return { errorMessage: `Failed to locate the appliedTo entity class ${appliesTo.name}.` };
39
- newClass.setAppliesTo(new ecschema_metadata_1.DelayedPromiseWithProps(newAppliesTo.key, async () => newAppliesTo));
40
- if (displayLabel)
41
- newClass.setDisplayLabel(displayLabel);
42
- return { itemKey: newClass.key };
43
- }
44
- /**
45
- * Creates a MixinClass through a MixinProps.
46
- * @param schemaKey a SchemaKey of the Schema that will house the new object.
47
- * @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.
48
- */
49
- async createFromProps(schemaKey, mixinProps) {
50
- const schema = await this._schemaEditor.getSchema(schemaKey);
51
- if (schema === undefined)
52
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
53
- if (mixinProps.name === undefined)
54
- return { errorMessage: `No name was supplied within props.` };
55
- const newClass = (await schema.createMixinClass(mixinProps.name));
56
- if (newClass === undefined)
57
- return { errorMessage: `Failed to create class ${mixinProps.name} in schema ${schemaKey.toString(true)}.` };
58
- await newClass.fromJSON(mixinProps);
59
- return { itemKey: newClass.key };
60
- }
61
- async addMixin(entityKey, mixinKey) {
62
- const entity = (await this._schemaEditor.schemaContext.getSchemaItem(entityKey));
63
- const mixin = (await this._schemaEditor.schemaContext.getSchemaItem(mixinKey));
64
- if (entity === undefined)
65
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${entityKey.fullName} not found in schema context.`);
66
- if (mixin === undefined)
67
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Mixin Class ${mixinKey.fullName} not found in schema context.`);
68
- if (entity.schemaItemType !== ecschema_metadata_1.SchemaItemType.EntityClass)
69
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${entityKey.fullName} to be of type Entity Class.`);
70
- if (mixin.schemaItemType !== ecschema_metadata_1.SchemaItemType.Mixin)
71
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${mixinKey.fullName} to be of type Mixin.`);
72
- entity.addMixin(mixin);
73
- }
74
- async createNavigationProperty(mixinKey, name, relationship, direction) {
75
- const mixin = (await this._schemaEditor.schemaContext.getSchemaItem(mixinKey));
76
- if (mixin === undefined)
77
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Mixin Class ${mixinKey.fullName} not found in schema context.`);
78
- if (mixin.schemaItemType !== ecschema_metadata_1.SchemaItemType.Mixin)
79
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${mixinKey.fullName} to be of type Mixin.`);
80
- await mixin.createNavigationProperty(name, relationship, direction);
81
- return { itemKey: mixinKey, propertyName: name };
82
- }
83
- }
84
- exports.Mixins = Mixins;
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.Mixins = void 0;
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ const ECClasses_1 = require("./ECClasses");
13
+ /**
14
+ * @alpha
15
+ * A class extending ECClasses allowing you to create schema items of type Mixin.
16
+ */
17
+ class Mixins extends ECClasses_1.ECClasses {
18
+ constructor(_schemaEditor) {
19
+ super(_schemaEditor);
20
+ }
21
+ async create(schemaKey, name, appliesTo, displayLabel, baseClass) {
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 newClass = (await schema.createMixinClass(name));
26
+ if (newClass === undefined)
27
+ return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
28
+ if (baseClass !== undefined) {
29
+ const baseClassItem = await schema.lookupItem(baseClass);
30
+ if (baseClassItem === undefined)
31
+ return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };
32
+ if (baseClassItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.Mixin)
33
+ return { errorMessage: `${baseClassItem.fullName} is not of type Mixin.` };
34
+ newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClass, async () => baseClassItem);
35
+ }
36
+ const newAppliesTo = (await this._schemaEditor.schemaContext.getSchemaItem(appliesTo));
37
+ if (newAppliesTo === undefined || newAppliesTo.schemaItemType !== ecschema_metadata_1.SchemaItemType.EntityClass)
38
+ return { errorMessage: `Failed to locate the appliedTo entity class ${appliesTo.name}.` };
39
+ newClass.setAppliesTo(new ecschema_metadata_1.DelayedPromiseWithProps(newAppliesTo.key, async () => newAppliesTo));
40
+ if (displayLabel)
41
+ newClass.setDisplayLabel(displayLabel);
42
+ return { itemKey: newClass.key };
43
+ }
44
+ /**
45
+ * Creates a MixinClass through a MixinProps.
46
+ * @param schemaKey a SchemaKey of the Schema that will house the new object.
47
+ * @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.
48
+ */
49
+ async createFromProps(schemaKey, mixinProps) {
50
+ const schema = await this._schemaEditor.getSchema(schemaKey);
51
+ if (schema === undefined)
52
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
53
+ if (mixinProps.name === undefined)
54
+ return { errorMessage: `No name was supplied within props.` };
55
+ const newClass = (await schema.createMixinClass(mixinProps.name));
56
+ if (newClass === undefined)
57
+ return { errorMessage: `Failed to create class ${mixinProps.name} in schema ${schemaKey.toString(true)}.` };
58
+ await newClass.fromJSON(mixinProps);
59
+ return { itemKey: newClass.key };
60
+ }
61
+ async addMixin(entityKey, mixinKey) {
62
+ const entity = (await this._schemaEditor.schemaContext.getSchemaItem(entityKey));
63
+ const mixin = (await this._schemaEditor.schemaContext.getSchemaItem(mixinKey));
64
+ if (entity === undefined)
65
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${entityKey.fullName} not found in schema context.`);
66
+ if (mixin === undefined)
67
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Mixin Class ${mixinKey.fullName} not found in schema context.`);
68
+ if (entity.schemaItemType !== ecschema_metadata_1.SchemaItemType.EntityClass)
69
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${entityKey.fullName} to be of type Entity Class.`);
70
+ if (mixin.schemaItemType !== ecschema_metadata_1.SchemaItemType.Mixin)
71
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${mixinKey.fullName} to be of type Mixin.`);
72
+ entity.addMixin(mixin);
73
+ }
74
+ async createNavigationProperty(mixinKey, name, relationship, direction) {
75
+ const mixin = (await this._schemaEditor.schemaContext.getSchemaItem(mixinKey));
76
+ if (mixin === undefined)
77
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Mixin Class ${mixinKey.fullName} not found in schema context.`);
78
+ if (mixin.schemaItemType !== ecschema_metadata_1.SchemaItemType.Mixin)
79
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${mixinKey.fullName} to be of type Mixin.`);
80
+ await mixin.createNavigationProperty(name, relationship, direction);
81
+ return { itemKey: mixinKey, propertyName: name };
82
+ }
83
+ }
84
+ exports.Mixins = Mixins;
85
85
  //# sourceMappingURL=Mixins.js.map
@@ -1,10 +1,10 @@
1
- import { CustomAttributeClass, CustomAttributeContainerType } from "@itwin/ecschema-metadata";
2
- /**
3
- * @internal
4
- * An abstract class used for Schema editing.
5
- */
6
- export declare abstract class MutableCAClass extends CustomAttributeClass {
7
- abstract setContainerType(containerType: CustomAttributeContainerType): void;
8
- abstract setDisplayLabel(displayLabel: string): void;
9
- }
1
+ import { CustomAttributeClass, CustomAttributeContainerType } from "@itwin/ecschema-metadata";
2
+ /**
3
+ * @internal
4
+ * An abstract class used for Schema editing.
5
+ */
6
+ export declare abstract class MutableCAClass extends CustomAttributeClass {
7
+ abstract setContainerType(containerType: CustomAttributeContainerType): void;
8
+ abstract setDisplayLabel(displayLabel: string): void;
9
+ }
10
10
  //# sourceMappingURL=MutableCAClass.d.ts.map