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

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 (104) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/lib/cjs/Editing/Constants.d.ts +20 -20
  3. package/lib/cjs/Editing/Constants.js +60 -60
  4. package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
  5. package/lib/cjs/Editing/CustomAttributes.js +59 -59
  6. package/lib/cjs/Editing/ECClasses.d.ts +54 -54
  7. package/lib/cjs/Editing/ECClasses.js +269 -269
  8. package/lib/cjs/Editing/Editor.d.ts +112 -112
  9. package/lib/cjs/Editing/Editor.js +166 -166
  10. package/lib/cjs/Editing/Entities.d.ts +25 -25
  11. package/lib/cjs/Editing/Entities.js +116 -116
  12. package/lib/cjs/Editing/Entities.js.map +1 -1
  13. package/lib/cjs/Editing/Enumerations.d.ts +21 -21
  14. package/lib/cjs/Editing/Enumerations.js +66 -66
  15. package/lib/cjs/Editing/Formats.d.ts +21 -21
  16. package/lib/cjs/Editing/Formats.js +61 -61
  17. package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
  18. package/lib/cjs/Editing/InvertedUnits.js +82 -82
  19. package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
  20. package/lib/cjs/Editing/KindOfQuantities.js +78 -78
  21. package/lib/cjs/Editing/Mixins.d.ts +22 -22
  22. package/lib/cjs/Editing/Mixins.js +84 -84
  23. package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
  24. package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
  25. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
  26. package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
  27. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
  28. package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
  29. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
  30. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
  31. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
  32. package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
  33. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
  34. package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
  35. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
  36. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
  37. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
  38. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
  39. package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
  40. package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
  41. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
  42. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
  43. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
  44. package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
  45. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
  46. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
  47. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
  48. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
  49. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
  50. package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
  51. package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
  52. package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
  53. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
  54. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
  55. package/lib/cjs/Editing/Phenomena.d.ts +15 -15
  56. package/lib/cjs/Editing/Phenomena.js +44 -44
  57. package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
  58. package/lib/cjs/Editing/PropertyCategories.js +51 -51
  59. package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
  60. package/lib/cjs/Editing/RelationshipClasses.js +68 -68
  61. package/lib/cjs/Editing/Structs.d.ts +19 -19
  62. package/lib/cjs/Editing/Structs.js +57 -57
  63. package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
  64. package/lib/cjs/Editing/UnitSystems.js +41 -41
  65. package/lib/cjs/Editing/Units.d.ts +15 -15
  66. package/lib/cjs/Editing/Units.js +58 -58
  67. package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
  68. package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
  69. package/lib/cjs/Validation/Diagnostic.js +310 -310
  70. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  71. package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
  72. package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
  73. package/lib/cjs/Validation/ECRules.d.ts +448 -448
  74. package/lib/cjs/Validation/ECRules.js +593 -593
  75. package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
  76. package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
  77. package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -59
  78. package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
  79. package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
  80. package/lib/cjs/Validation/Rules.d.ts +64 -64
  81. package/lib/cjs/Validation/Rules.d.ts.map +1 -1
  82. package/lib/cjs/Validation/Rules.js +9 -9
  83. package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
  84. package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
  85. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
  86. package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
  87. package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
  88. package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
  89. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
  90. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
  91. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
  92. package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
  93. package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
  94. package/lib/cjs/Validation/SchemaComparer.js +666 -666
  95. package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
  96. package/lib/cjs/Validation/SchemaValidater.js +61 -61
  97. package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
  98. package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -492
  99. package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
  100. package/lib/cjs/Validation/SchemaWalker.js +51 -51
  101. package/lib/cjs/ecschema-editing.d.ts +33 -33
  102. package/lib/cjs/ecschema-editing.js +58 -54
  103. package/lib/cjs/ecschema-editing.js.map +1 -1
  104. package/package.json +12 -12
package/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Change Log - @itwin/ecschema-editing
2
2
 
3
- This log was last generated on Thu, 26 Jan 2023 22:53:27 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 08 Feb 2023 14:58:40 GMT and should not be manually modified.
4
+
5
+ ## 3.6.0
6
+ Wed, 08 Feb 2023 14:58:40 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 3.5.6
11
+ Fri, 24 Feb 2023 16:02:47 GMT
12
+
13
+ _Version update only_
4
14
 
5
15
  ## 3.5.5
6
16
  Thu, 26 Jan 2023 22:53:27 GMT
@@ -1,21 +1,21 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { ConstantProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
5
- import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
- /**
7
- * @alpha
8
- * A class allowing you to create schema items of type Constant.
9
- */
10
- export declare class Constants {
11
- protected _schemaEditor: SchemaContextEditor;
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- create(schemaKey: SchemaKey, name: string, phenomenon: SchemaItemKey, definition: string, displayLabel?: string, numerator?: number, denominator?: number): Promise<SchemaItemEditResults>;
14
- /**
15
- * Creates a Constant through a ConstantProps.
16
- * @param schemaKey a SchemaKey of the Schema that will house the new object.
17
- * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
18
- */
19
- createFromProps(schemaKey: SchemaKey, constantProps: ConstantProps): Promise<SchemaItemEditResults>;
20
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { ConstantProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
5
+ import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ /**
7
+ * @alpha
8
+ * A class allowing you to create schema items of type Constant.
9
+ */
10
+ export declare class Constants {
11
+ protected _schemaEditor: SchemaContextEditor;
12
+ constructor(_schemaEditor: SchemaContextEditor);
13
+ create(schemaKey: SchemaKey, name: string, phenomenon: SchemaItemKey, definition: string, displayLabel?: string, numerator?: number, denominator?: number): Promise<SchemaItemEditResults>;
14
+ /**
15
+ * Creates a Constant through a ConstantProps.
16
+ * @param schemaKey a SchemaKey of the Schema that will house the new object.
17
+ * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
18
+ */
19
+ createFromProps(schemaKey: SchemaKey, constantProps: ConstantProps): Promise<SchemaItemEditResults>;
20
+ }
21
21
  //# sourceMappingURL=Constants.d.ts.map
@@ -1,61 +1,61 @@
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.Constants = 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 Constant.
15
- */
16
- class Constants {
17
- constructor(_schemaEditor) {
18
- this._schemaEditor = _schemaEditor;
19
- }
20
- async create(schemaKey, name, phenomenon, definition, displayLabel, numerator, denominator) {
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 newConstant = (await schema.createConstant(name));
25
- if (newConstant === undefined) {
26
- return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
27
- }
28
- const newPhenomenon = (await this._schemaEditor.schemaContext.getSchemaItem(phenomenon));
29
- if (newPhenomenon === undefined || newPhenomenon.schemaItemType !== ecschema_metadata_1.SchemaItemType.Phenomenon) {
30
- return { errorMessage: `Unable to locate phenomenon ${phenomenon.name}` };
31
- }
32
- newConstant.setPhenomenon(new ecschema_metadata_1.DelayedPromiseWithProps(newPhenomenon.key, async () => newPhenomenon));
33
- newConstant.setDefinition(definition);
34
- if (numerator)
35
- newConstant.setNumerator(numerator);
36
- if (denominator)
37
- newConstant.setDenominator(denominator);
38
- if (displayLabel)
39
- newConstant.setDisplayLabel(displayLabel);
40
- return { itemKey: newConstant.key };
41
- }
42
- /**
43
- * Creates a Constant through a ConstantProps.
44
- * @param schemaKey a SchemaKey of the Schema that will house the new object.
45
- * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
46
- */
47
- async createFromProps(schemaKey, constantProps) {
48
- const schema = await this._schemaEditor.getSchema(schemaKey);
49
- if (schema === undefined)
50
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
51
- if (constantProps.name === undefined)
52
- return { errorMessage: `No name was supplied within props.` };
53
- const newConstant = (await schema.createConstant(constantProps.name));
54
- if (newConstant === undefined)
55
- return { errorMessage: `Failed to create class ${constantProps.name} in schema ${schemaKey.toString(true)}.` };
56
- await newConstant.fromJSON(constantProps);
57
- return { itemKey: newConstant.key };
58
- }
59
- }
60
- exports.Constants = Constants;
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.Constants = 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 Constant.
15
+ */
16
+ class Constants {
17
+ constructor(_schemaEditor) {
18
+ this._schemaEditor = _schemaEditor;
19
+ }
20
+ async create(schemaKey, name, phenomenon, definition, displayLabel, numerator, denominator) {
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 newConstant = (await schema.createConstant(name));
25
+ if (newConstant === undefined) {
26
+ return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
27
+ }
28
+ const newPhenomenon = (await this._schemaEditor.schemaContext.getSchemaItem(phenomenon));
29
+ if (newPhenomenon === undefined || newPhenomenon.schemaItemType !== ecschema_metadata_1.SchemaItemType.Phenomenon) {
30
+ return { errorMessage: `Unable to locate phenomenon ${phenomenon.name}` };
31
+ }
32
+ newConstant.setPhenomenon(new ecschema_metadata_1.DelayedPromiseWithProps(newPhenomenon.key, async () => newPhenomenon));
33
+ newConstant.setDefinition(definition);
34
+ if (numerator)
35
+ newConstant.setNumerator(numerator);
36
+ if (denominator)
37
+ newConstant.setDenominator(denominator);
38
+ if (displayLabel)
39
+ newConstant.setDisplayLabel(displayLabel);
40
+ return { itemKey: newConstant.key };
41
+ }
42
+ /**
43
+ * Creates a Constant through a ConstantProps.
44
+ * @param schemaKey a SchemaKey of the Schema that will house the new object.
45
+ * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
46
+ */
47
+ async createFromProps(schemaKey, constantProps) {
48
+ const schema = await this._schemaEditor.getSchema(schemaKey);
49
+ if (schema === undefined)
50
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
51
+ if (constantProps.name === undefined)
52
+ return { errorMessage: `No name was supplied within props.` };
53
+ const newConstant = (await schema.createConstant(constantProps.name));
54
+ if (newConstant === undefined)
55
+ return { errorMessage: `Failed to create class ${constantProps.name} in schema ${schemaKey.toString(true)}.` };
56
+ await newConstant.fromJSON(constantProps);
57
+ return { itemKey: newConstant.key };
58
+ }
59
+ }
60
+ exports.Constants = Constants;
61
61
  //# sourceMappingURL=Constants.js.map
@@ -1,21 +1,21 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { CustomAttributeClassProps, CustomAttributeContainerType, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
5
- import { 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 CustomAttributeClass.
10
- */
11
- export declare class CustomAttributes extends ECClasses {
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- create(schemaKey: SchemaKey, name: string, containerType: CustomAttributeContainerType, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
14
- /**
15
- * Creates a CustomAttributeClass through a CustomAttributeClassProps.
16
- * @param schemaKey a SchemaKey of the Schema that will house the new object.
17
- * @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.
18
- */
19
- createFromProps(schemaKey: SchemaKey, caProps: CustomAttributeClassProps): Promise<SchemaItemEditResults>;
20
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { CustomAttributeClassProps, CustomAttributeContainerType, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
5
+ import { 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 CustomAttributeClass.
10
+ */
11
+ export declare class CustomAttributes extends ECClasses {
12
+ constructor(_schemaEditor: SchemaContextEditor);
13
+ create(schemaKey: SchemaKey, name: string, containerType: CustomAttributeContainerType, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
14
+ /**
15
+ * Creates a CustomAttributeClass through a CustomAttributeClassProps.
16
+ * @param schemaKey a SchemaKey of the Schema that will house the new object.
17
+ * @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.
18
+ */
19
+ createFromProps(schemaKey: SchemaKey, caProps: CustomAttributeClassProps): Promise<SchemaItemEditResults>;
20
+ }
21
21
  //# sourceMappingURL=CustomAttributes.d.ts.map
@@ -1,60 +1,60 @@
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.CustomAttributes = 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 CustomAttributeClass.
16
- */
17
- class CustomAttributes extends ECClasses_1.ECClasses {
18
- constructor(_schemaEditor) {
19
- super(_schemaEditor);
20
- }
21
- async create(schemaKey, name, containerType, 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.createCustomAttributeClass(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.CustomAttributeClass)
33
- return { errorMessage: `${baseClassItem.fullName} is not of type CustomAttribute Class.` };
34
- newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClass, async () => baseClassItem);
35
- }
36
- if (displayLabel)
37
- newClass.setDisplayLabel(displayLabel);
38
- newClass.setContainerType(containerType);
39
- return { itemKey: newClass.key };
40
- }
41
- /**
42
- * Creates a CustomAttributeClass through a CustomAttributeClassProps.
43
- * @param schemaKey a SchemaKey of the Schema that will house the new object.
44
- * @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.
45
- */
46
- async createFromProps(schemaKey, caProps) {
47
- const schema = await this._schemaEditor.getSchema(schemaKey);
48
- if (schema === undefined)
49
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
50
- if (caProps.name === undefined)
51
- return { errorMessage: `No name was supplied within props.` };
52
- const newClass = (await schema.createCustomAttributeClass(caProps.name));
53
- if (newClass === undefined)
54
- return { errorMessage: `Failed to create class ${caProps.name} in schema ${schemaKey.toString(true)}.` };
55
- await newClass.fromJSON(caProps);
56
- return { itemKey: newClass.key };
57
- }
58
- }
59
- exports.CustomAttributes = CustomAttributes;
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.CustomAttributes = 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 CustomAttributeClass.
16
+ */
17
+ class CustomAttributes extends ECClasses_1.ECClasses {
18
+ constructor(_schemaEditor) {
19
+ super(_schemaEditor);
20
+ }
21
+ async create(schemaKey, name, containerType, 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.createCustomAttributeClass(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.CustomAttributeClass)
33
+ return { errorMessage: `${baseClassItem.fullName} is not of type CustomAttribute Class.` };
34
+ newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClass, async () => baseClassItem);
35
+ }
36
+ if (displayLabel)
37
+ newClass.setDisplayLabel(displayLabel);
38
+ newClass.setContainerType(containerType);
39
+ return { itemKey: newClass.key };
40
+ }
41
+ /**
42
+ * Creates a CustomAttributeClass through a CustomAttributeClassProps.
43
+ * @param schemaKey a SchemaKey of the Schema that will house the new object.
44
+ * @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.
45
+ */
46
+ async createFromProps(schemaKey, caProps) {
47
+ const schema = await this._schemaEditor.getSchema(schemaKey);
48
+ if (schema === undefined)
49
+ return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
50
+ if (caProps.name === undefined)
51
+ return { errorMessage: `No name was supplied within props.` };
52
+ const newClass = (await schema.createCustomAttributeClass(caProps.name));
53
+ if (newClass === undefined)
54
+ return { errorMessage: `Failed to create class ${caProps.name} in schema ${schemaKey.toString(true)}.` };
55
+ await newClass.fromJSON(caProps);
56
+ return { itemKey: newClass.key };
57
+ }
58
+ }
59
+ exports.CustomAttributes = CustomAttributes;
60
60
  //# sourceMappingURL=CustomAttributes.js.map
@@ -1,55 +1,55 @@
1
- /** @packageDocumentation
2
- * @module Editing
3
- */
4
- import { CustomAttribute, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PrimitiveType, SchemaItemKey, StructArrayPropertyProps, StructClass, StructPropertyProps } from "@itwin/ecschema-metadata";
5
- import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
- /**
7
- * @alpha
8
- * Acts as a base class for schema class creation. Enables property creation.
9
- */
10
- export declare class ECClasses {
11
- protected _schemaEditor: SchemaContextEditor;
12
- protected constructor(_schemaEditor: SchemaContextEditor);
13
- /**
14
- * Creates a property on class identified by the given SchemaItemKey. This method restricts the
15
- * property type to primitives of type Double, String, DateTime and Integer.
16
- * @param classKey The SchemaItemKey of the class.
17
- * @param name The name of the new property.
18
- * @param type The PrimitiveType assigned to the new property.
19
- */
20
- createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<PropertyEditResults>;
21
- /**
22
- * Create a primitive property on class identified by the given SchemaItemKey.
23
- * @param classKey The SchemaItemKey of the class.
24
- * @param name The name of the new property.
25
- * @param type The PrimitiveType assigned to the new property.
26
- */
27
- createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults>;
28
- createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults>;
29
- createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults>;
30
- createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults>;
31
- createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults>;
32
- createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults>;
33
- createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults>;
34
- createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults>;
35
- createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults>;
36
- createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults>;
37
- deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults>;
38
- delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults>;
39
- /**
40
- * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey
41
- * @param classKey The SchemaItemKey identifying the schema.
42
- * @param customAttribute The CustomAttribute instance to add.
43
- */
44
- addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults>;
45
- /**
46
- * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.
47
- * @param classKey The SchemaItemKey identifying the class.
48
- * @param propertyName The name of the property.
49
- * @param customAttribute The CustomAttribute instance to add.
50
- */
51
- addCustomAttributeToProperty(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute): Promise<PropertyEditResults>;
52
- private getClass;
53
- private removeCustomAttribute;
54
- }
1
+ /** @packageDocumentation
2
+ * @module Editing
3
+ */
4
+ import { CustomAttribute, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PrimitiveType, SchemaItemKey, StructArrayPropertyProps, StructClass, StructPropertyProps } from "@itwin/ecschema-metadata";
5
+ import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ /**
7
+ * @alpha
8
+ * Acts as a base class for schema class creation. Enables property creation.
9
+ */
10
+ export declare class ECClasses {
11
+ protected _schemaEditor: SchemaContextEditor;
12
+ protected constructor(_schemaEditor: SchemaContextEditor);
13
+ /**
14
+ * Creates a property on class identified by the given SchemaItemKey. This method restricts the
15
+ * property type to primitives of type Double, String, DateTime and Integer.
16
+ * @param classKey The SchemaItemKey of the class.
17
+ * @param name The name of the new property.
18
+ * @param type The PrimitiveType assigned to the new property.
19
+ */
20
+ createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<PropertyEditResults>;
21
+ /**
22
+ * Create a primitive property on class identified by the given SchemaItemKey.
23
+ * @param classKey The SchemaItemKey of the class.
24
+ * @param name The name of the new property.
25
+ * @param type The PrimitiveType assigned to the new property.
26
+ */
27
+ createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults>;
28
+ createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults>;
29
+ createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults>;
30
+ createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults>;
31
+ createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults>;
32
+ createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults>;
33
+ createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults>;
34
+ createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults>;
35
+ createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults>;
36
+ createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults>;
37
+ deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults>;
38
+ delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults>;
39
+ /**
40
+ * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey
41
+ * @param classKey The SchemaItemKey identifying the schema.
42
+ * @param customAttribute The CustomAttribute instance to add.
43
+ */
44
+ addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults>;
45
+ /**
46
+ * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.
47
+ * @param classKey The SchemaItemKey identifying the class.
48
+ * @param propertyName The name of the property.
49
+ * @param customAttribute The CustomAttribute instance to add.
50
+ */
51
+ addCustomAttributeToProperty(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute): Promise<PropertyEditResults>;
52
+ private getClass;
53
+ private removeCustomAttribute;
54
+ }
55
55
  //# sourceMappingURL=ECClasses.d.ts.map