@itwin/ecschema-editing 5.5.0-dev.2 → 5.5.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1
- package/lib/cjs/Differencing/Errors.js.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
- package/lib/cjs/Differencing/Utils.js.map +1 -1
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Exception.js.map +1 -1
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchemaItem.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
- package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
- package/lib/cjs/Merging/FormatMerger.js.map +1 -1
- package/lib/cjs/Merging/InvertedUnitMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/cjs/Merging/Utils.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/cjs/Validation/Rules.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/lib/esm/Differencing/Errors.js.map +1 -1
- package/lib/esm/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/esm/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/esm/Differencing/SchemaDifference.js.map +1 -1
- package/lib/esm/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/esm/Differencing/SchemaDifferenceVisitor.js.map +1 -1
- package/lib/esm/Differencing/Utils.js.map +1 -1
- package/lib/esm/Editing/Constants.js.map +1 -1
- package/lib/esm/Editing/CustomAttributes.js.map +1 -1
- package/lib/esm/Editing/ECClasses.js.map +1 -1
- package/lib/esm/Editing/Editor.js.map +1 -1
- package/lib/esm/Editing/Entities.js.map +1 -1
- package/lib/esm/Editing/Enumerations.js.map +1 -1
- package/lib/esm/Editing/Exception.js.map +1 -1
- package/lib/esm/Editing/Formats.js.map +1 -1
- package/lib/esm/Editing/InvertedUnits.js.map +1 -1
- package/lib/esm/Editing/KindOfQuantities.js.map +1 -1
- package/lib/esm/Editing/Mixins.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableArrayProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableConstant.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableEnumeration.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutablePhenomenon.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableSchemaItem.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableStructProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableUnit.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/esm/Editing/Phenomena.js.map +1 -1
- package/lib/esm/Editing/Properties.js.map +1 -1
- package/lib/esm/Editing/PropertyCategories.js.map +1 -1
- package/lib/esm/Editing/RelationshipClasses.js.map +1 -1
- package/lib/esm/Editing/SchemaItems.js.map +1 -1
- package/lib/esm/Editing/Structs.js.map +1 -1
- package/lib/esm/Editing/UnitSystems.js.map +1 -1
- package/lib/esm/Editing/Units.js.map +1 -1
- package/lib/esm/Merging/ClassMerger.js.map +1 -1
- package/lib/esm/Merging/ConstantMerger.js.map +1 -1
- package/lib/esm/Merging/CustomAttributeClassMerger.js.map +1 -1
- package/lib/esm/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/esm/Merging/Edits/NameMapping.js.map +1 -1
- package/lib/esm/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/esm/Merging/Edits/SchemaEdits.js.map +1 -1
- package/lib/esm/Merging/Edits/SkipEditHandler.js.map +1 -1
- package/lib/esm/Merging/EntityClassMerger.js.map +1 -1
- package/lib/esm/Merging/EnumerationMerger.js.map +1 -1
- package/lib/esm/Merging/EnumeratorMerger.js.map +1 -1
- package/lib/esm/Merging/FormatMerger.js.map +1 -1
- package/lib/esm/Merging/InvertedUnitMerger.js.map +1 -1
- package/lib/esm/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/esm/Merging/MixinMerger.js.map +1 -1
- package/lib/esm/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/esm/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/esm/Merging/PropertyMerger.js.map +1 -1
- package/lib/esm/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/esm/Merging/SchemaMerger.js.map +1 -1
- package/lib/esm/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/esm/Merging/SchemaMergingWalker.js.map +1 -1
- package/lib/esm/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/esm/Merging/StructClassMerger.js.map +1 -1
- package/lib/esm/Merging/UnitMerger.js.map +1 -1
- package/lib/esm/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/esm/Merging/Utils.js.map +1 -1
- package/lib/esm/Validation/Diagnostic.js.map +1 -1
- package/lib/esm/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/esm/Validation/ECRules.js.map +1 -1
- package/lib/esm/Validation/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/esm/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/esm/Validation/Rules.js.map +1 -1
- package/lib/esm/Validation/SchemaChanges.js.map +1 -1
- package/lib/esm/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/esm/Validation/SchemaCompareReporter.js.map +1 -1
- package/lib/esm/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/esm/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/esm/Validation/SchemaComparer.js.map +1 -1
- package/lib/esm/Validation/SchemaValidater.js.map +1 -1
- package/lib/esm/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/ecschema-editing.js.map +1 -1
- package/package.json +9 -9
- package/public/locales/en/ECSchemaEditing.json +26 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutableUnit.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableUnit.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA4F;AAE5F;;;GAGG;AACH,MAAsB,WAAY,SAAQ,wBAAI;CAK7C;AALD,kCAKC","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*--------------------------------------------------------------------------------------------*/\nimport { LazyLoadedPhenomenon, LazyLoadedUnitSystem, Unit } from \"@itwin/ecschema-metadata\";\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableUnit extends Unit {\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;\n public abstract override setDefinition(definition: string): Promise<void>;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MutableUnit.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableUnit.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA4F;AAE5F;;;GAGG;AACH,MAAsB,WAAY,SAAQ,wBAAI;CAK7C;AALD,kCAKC","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\nimport { LazyLoadedPhenomenon, LazyLoadedUnitSystem, Unit } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableUnit extends Unit {\r\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;\r\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;\r\n public abstract override setDefinition(definition: string): Promise<void>;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutableUnitSystem.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableUnitSystem.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAsD;AAEtD;;;GAGG;AACH,MAAsB,iBAAkB,SAAQ,8BAAU;CAGzD;AAHD,8CAGC","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*--------------------------------------------------------------------------------------------*/\nimport { UnitSystem } from \"@itwin/ecschema-metadata\";\n\n/**\n * @internal\n * Used for schema editing.\n */\nexport abstract class MutableUnitSystem extends UnitSystem {\n public abstract override setDisplayLabel(displayLabel: string): void;\n public abstract override setDescription(description: string): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MutableUnitSystem.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableUnitSystem.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAsD;AAEtD;;;GAGG;AACH,MAAsB,iBAAkB,SAAQ,8BAAU;CAGzD;AAHD,8CAGC","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\nimport { UnitSystem } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * @internal\r\n * Used for schema editing.\r\n */\r\nexport abstract class MutableUnitSystem extends UnitSystem {\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n public abstract override setDescription(description: string): void;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Phenomena.js","sourceRoot":"","sources":["../../../src/Editing/Phenomena.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiH;AAGjH,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,SAAU,SAAQ,yBAAW;IACxC,IAAuB,aAAa;QAClC,OAAO,8B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E,eAAe,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;CACF;AAhCD,8BAgCC","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 { Phenomenon, PhenomenonProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutablePhenomenon } from \"./Mutable/MutablePhenomenon\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Phenomenon.\n */\nexport class Phenomena extends SchemaItems {\n protected override get itemTypeClass(): typeof Phenomenon {\n return Phenomenon;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Phenomenon, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newPhenomenon = await this.createSchemaItem<Phenomenon>(schemaKey, this.schemaItemType, (schema) => schema.createPhenomenon.bind(schema), name) as MutablePhenomenon;\n\n if (displayLabel)\n newPhenomenon.setDisplayLabel(displayLabel);\n\n await newPhenomenon.setDefinition(definition);\n\n return newPhenomenon.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, phenomenonProps: PhenomenonProps): Promise<SchemaItemKey> {\n try {\n const newPhenomenon = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPhenomenon.bind(schema), phenomenonProps);\n return newPhenomenon.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, phenomenonProps.name!, schemaKey), e);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Phenomena.js","sourceRoot":"","sources":["../../../src/Editing/Phenomena.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiH;AAGjH,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,SAAU,SAAQ,yBAAW;IACxC,IAAuB,aAAa;QAClC,OAAO,8BAAU,CAAC;IACpB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,YAAqB;QAC/F,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAsB,CAAC;YAE3K,IAAI,YAAY;gBACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAE9C,MAAM,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAE9C,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC;YAC9J,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;CACF;AAhCD,8BAgCC","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 { Phenomenon, PhenomenonProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutablePhenomenon } from \"./Mutable/MutablePhenomenon\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Phenomenon.\r\n */\r\nexport class Phenomena extends SchemaItems {\r\n protected override get itemTypeClass(): typeof Phenomenon {\r\n return Phenomenon;\r\n }\r\n\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.Phenomenon, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, definition: string, displayLabel?: string): Promise<SchemaItemKey> {\r\n try {\r\n const newPhenomenon = await this.createSchemaItem<Phenomenon>(schemaKey, this.schemaItemType, (schema) => schema.createPhenomenon.bind(schema), name) as MutablePhenomenon;\r\n\r\n if (displayLabel)\r\n newPhenomenon.setDisplayLabel(displayLabel);\r\n\r\n await newPhenomenon.setDefinition(definition);\r\n\r\n return newPhenomenon.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, phenomenonProps: PhenomenonProps): Promise<SchemaItemKey> {\r\n try {\r\n const newPhenomenon = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPhenomenon.bind(schema), phenomenonProps);\r\n return newPhenomenon.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, phenomenonProps.name!, schemaKey), e);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Properties.js","sourceRoot":"","sources":["../../../src/Editing/Properties.ts"],"names":[],"mappings":";;;AAAA,gEAEoF;AACpF,sDAA6C;AAE7C,+CAA+C;AAQ/C,2CAAsI;AAKtI;;;GAGG;AACH,MAAa,UAAU;IACQ;IAA2C;IAAxE,YAA6B,WAA+B,EAAY,aAAkC;QAA7E,gBAAW,GAAX,WAAW,CAAoB;QAAY,kBAAa,GAAb,aAAa,CAAqB;IAC1G,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAuB,EAAE,YAAoB,EAAE,eAAuB;QACzF,IAAI,OAAe,CAAC;QACpB,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,0BAAM,CAAC,eAAe,CAAC,CAAC;QACxC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,eAAe,EAAE,IAAI,sBAAU,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,YAAY,CAAC,EACpH,IAAI,8BAAkB,CAAC,2BAAe,CAAC,aAAa,EAAE,IAAI,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B,CAAC,cAAc,CAAC,CAAC,CAAC;QAC/J,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAjBD,4CAiBC","sourcesContent":["import { CustomAttribute, CustomAttributeContainerProps, DelayedPromiseWithProps, ECClass, ECName,\n EnumerationProperty, KindOfQuantity, NavigationProperty, PrimitiveProperty,\n PropertyCategory, SchemaItemKey, StructProperty } from \"@itwin/ecschema-metadata\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { MutableArrayProperty } from \"./Mutable/MutableArrayProperty\";\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\nimport { MutablePrimitiveOrEnumPropertyBase } from \"./Mutable/MutablePrimitiveOrEnumProperty\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\nimport { MutableStructProperty } from \"./Mutable/MutableStructProperty\";\nimport { MutableNavigationProperty } from \"./Mutable/MutableNavigationProperty\";\nimport { ECClassSchemaItems } from \"./ECClasses\";\nimport { ClassId, CustomAttributeId, ECEditingStatus, PropertyId, PropertyTypeName, SchemaEditingError, SchemaId } from \"./Exception\";\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\n\ntype MutablePropertyType = MutableProperty | MutableArrayProperty | MutablePrimitiveOrEnumPropertyBase | MutableNavigationProperty | MutableStructProperty;\n\n/**\n * @alpha\n * A class allowing editing of attributes of the base Property class.\n */\nexport class Properties {\n public constructor(protected ecClassType: ECClassSchemaItems, protected _schemaEditor: SchemaContextEditor) {\n }\n\n public async setName(classKey: SchemaItemKey, propertyName: string, newPropertyName: string) {\n let newName: ECName;\n try {\n newName = new ECName(newPropertyName);\n } catch {\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName),\n new SchemaEditingError(ECEditingStatus.InvalidECName, new PropertyId(this.ecClassType, classKey, newPropertyName)));\n }\n\n const existingProperty = await this.getProperty<MutableProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n\n const existingNewProperty = await existingProperty.class.getProperty(newPropertyName) as MutableProperty;\n if (existingNewProperty) {\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName),\n new SchemaEditingError(ECEditingStatus.PropertyAlreadyExists, new PropertyId(this.ecClassType, existingNewProperty.class.key, newPropertyName)));\n }\n\n // Handle derived classes\n const derivedProperties: Array<MutableProperty> = [];\n const derivedClasses = await this.findDerivedClasses(existingProperty.class as MutableClass);\n for (const derivedClass of derivedClasses) {\n if (await derivedClass.getProperty(newPropertyName, true)) {\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName),\n new SchemaEditingError(ECEditingStatus.PropertyAlreadyExists, new PropertyId(this.ecClassType, derivedClass.key, newPropertyName)));\n }\n\n const propertyOverride = await derivedClass.getProperty(propertyName, true) as MutableProperty;\n // If found the property is overridden in the derived class.\n if (propertyOverride)\n derivedProperties.push(propertyOverride);\n }\n\n // Re-name the overridden property in all derived classes\n derivedProperties.forEach((prop: MutableProperty) => {\n prop.setName(newName);\n });\n\n existingProperty.setName(newName);\n }\n\n /**\n * Sets the property description.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param description The new description to set.\n */\n public async setDescription(classKey: SchemaItemKey, propertyName: string, description: string) {\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setDescription(description);\n }\n\n /**\n * Sets the property label.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param label The new label to set.\n */\n public async setLabel(classKey: SchemaItemKey, propertyName: string, label: string) {\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setLabel(label);\n }\n\n /**\n * Sets the property isReadOnly attribute.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param isReadOnly The new isReadOnly value.\n */\n public async setIsReadOnly(classKey: SchemaItemKey, propertyName: string, isReadOnly: boolean) {\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetIsReadOnly, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setIsReadOnly(isReadOnly);\n }\n\n /**\n * Sets the property priority.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param priority The new priority.\n */\n public async setPriority(classKey: SchemaItemKey, propertyName: string, priority: number) {\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetPriority, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setPriority(priority);\n }\n\n /**\n * Sets the property category.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param categoryKey The SchemaItemKey of the property category.\n */\n public async setCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey) {\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetCategory, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n\n const category = await this._schemaEditor.getSchemaItem(categoryKey, PropertyCategory)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetCategory, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n\n property.setCategory(new DelayedPromiseWithProps<SchemaItemKey, PropertyCategory>(categoryKey, async () => category));\n }\n\n /**\n * Sets the KindOfQuantity of a property.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param kindOfQuantityKey The SchemaItemKey of the KindOfQuantity.\n */\n public async setKindOfQuantity(classKey: SchemaItemKey, propertyName: string, kindOfQuantityKey: SchemaItemKey) {\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetKindOfQuantity, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n\n const koq = await this._schemaEditor.getSchemaItem(kindOfQuantityKey, KindOfQuantity)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetKindOfQuantity, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n\n const currentKoq = await property.kindOfQuantity;\n if(currentKoq && currentKoq.persistenceUnit && koq.persistenceUnit && !currentKoq.persistenceUnit.matchesFullName(koq.persistenceUnit.fullName)) {\n throw new SchemaEditingError(ECEditingStatus.SetKindOfQuantity, new PropertyId(this.ecClassType, classKey, propertyName), undefined, undefined, \"KindOfQuantity can only be changed if it has the same persistence unit as the property.\");\n }\n\n property.setKindOfQuantity(new DelayedPromiseWithProps<SchemaItemKey, KindOfQuantity>(kindOfQuantityKey, async () => koq));\n }\n\n /**\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\n * @param classKey The SchemaItemKey identifying the class.\n * @param propertyName The name of the property.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute) {\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToProperty, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n\n property.addCustomAttribute(customAttribute);\n\n const diagnosticsIterable = Rules.validateCustomAttributeInstance(property, customAttribute);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of diagnosticsIterable) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeCustomAttribute(property, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToProperty, new PropertyId(this.ecClassType, classKey, propertyName),\n new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, property)));\n }\n }\n\n /**\n * Removes a CustomAttribute from a property.\n * @param container\n * @param customAttribute\n */\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\n assert(container.customAttributes !== undefined);\n const map = container.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n\n /**\n * Gets the property with the specified name from the class identified by the given key.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property to retrieve.\n */\n protected async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\n const mutableClass = await this.getClass(classKey);\n\n const property = await mutableClass.getProperty(propertyName, true) as T;\n if (property === undefined) {\n throw new SchemaEditingError(ECEditingStatus.PropertyNotFound, new PropertyId(mutableClass.schemaItemType as ECClassSchemaItems, classKey, propertyName));\n }\n\n return property;\n }\n\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\n const derivedClasses: Array<MutableClass> = [];\n\n for (const schemaItem of this._schemaEditor.schemaContext.getSchemaItems()) {\n if(ECClass.isECClass(schemaItem) && await schemaItem.is(mutableClass)) {\n if (!mutableClass.key.matches(schemaItem.key)) {\n derivedClasses.push(schemaItem as MutableClass);\n }\n }\n }\n\n return derivedClasses;\n }\n\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(classKey.schemaKey));\n\n const ecClass = await schema.getItem(classKey.name);\n if (ecClass === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new ClassId(this.ecClassType, classKey));\n\n if (ecClass.schemaItemType !== this.ecClassType){\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new ClassId(this.ecClassType, classKey));\n }\n\n return ecClass as MutableClass;\n }\n}\n\n/**\n * @alpha\n * A class extending Properties allowing editing of attributes of PrimitiveArrayProperty,\n * EnumerationArrayProperty and StructArrayProperty.\n */\nexport class ArrayProperties extends Properties {\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\n super(ecClassType, _schemaEditor);\n }\n\n /**\n * Sets the array property minOccurs attribute.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param minOccurs The new minOccurs value.\n */\n public async setMinOccurs(classKey: SchemaItemKey, propertyName: string, minOccurs: number) {\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetMinOccurs, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setMinOccurs(minOccurs);\n }\n\n /**\n * Sets the array property maxOccurs attribute.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param maxOccurs The new maxOccurs value.\n */\n public async setMaxOccurs(classKey: SchemaItemKey, propertyName: string, maxOccurs: number) {\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetMaxOccurs, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setMaxOccurs(maxOccurs);\n }\n\n /**\n * Override to validate that the found property is an ArrayProperty.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n */\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\n const property = await super.getProperty<MutableArrayProperty>(classKey, propertyName) as T;\n if (!property.isArray()){\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.ArrayProperty));\n }\n return property;\n }\n}\n\n/**\n * @alpha\n * A class extending Properties allowing editing of attributes of PrimitiveProperty and EnumerationProperty.\n */\nclass PrimitiveOrEnumProperties extends Properties {\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\n super(ecClassType, _schemaEditor);\n }\n\n /**\n * Sets the extendedTypeName attribute value.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param extendedTypeName The extended type name of the property.\n */\n public async setExtendedTypeName(classKey: SchemaItemKey, propertyName: string, extendedTypeName: string) {\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetExtendedTypeName, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setExtendedTypeName(extendedTypeName);\n }\n\n /**\n * Sets the minLength attribute value.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param minLength The minimum length of the property.\n */\n public async setMinLength(classKey: SchemaItemKey, propertyName: string, minLength: number) {\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetMinLength, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setMinLength(minLength);\n }\n\n /**\n * Sets the maxLength attribute value.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param maxLength The maximum length of the property.\n */\n public async setMaxLength(classKey: SchemaItemKey, propertyName: string, maxLength: number) {\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetMaxLength, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setMaxLength(maxLength);\n }\n\n /**\n * Sets the minValue attribute value.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param minValue The minimum value of the property.\n */\n public async setMinValue(classKey: SchemaItemKey, propertyName: string, minValue: number) {\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetMinValue, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setMinValue(minValue);\n }\n\n /**\n * Sets the maxValue attribute value.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param maxValue The maximum value of the property.\n */\n public async setMaxValue(classKey: SchemaItemKey, propertyName: string, maxValue: number) {\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetMaxValue, new PropertyId(this.ecClassType, classKey, propertyName), e);\n });\n property.setMaxValue(maxValue);\n }\n}\n\n/**\n * @alpha\n * A class extending Properties allowing editing of PrimitiveProperty attributes.\n */\nexport class PrimitiveProperties extends PrimitiveOrEnumProperties {\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\n super(ecClassType, _schemaEditor);\n }\n\n /**\n * Override to validate that the found property is a PrimitiveProperty.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n */\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\n if (!(property instanceof PrimitiveProperty)){\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.PrimitiveProperty));\n }\n return property;\n }\n}\n\n/**\n * @alpha\n * A class extending Properties allowing editing of EnumerationProperty attributes.\n */\nexport class EnumerationProperties extends PrimitiveOrEnumProperties {\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\n super(ecClassType, _schemaEditor);\n }\n\n /**\n * Override to validate that the found property is a EnumerationProperty.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n */\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\n if (!(property instanceof EnumerationProperty)){\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.EnumerationProperty));\n }\n return property;\n }\n}\n\n/**\n * @alpha\n * A class extending Properties allowing editing of NavigationProperties attributes.\n */\nexport class NavigationProperties extends Properties {\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\n super(ecClassType, _schemaEditor);\n }\n\n /**\n * Override to validate that the found property is a NavigationProperty.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n */\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\n const property = await super.getProperty<MutableNavigationProperty>(classKey, propertyName) as T;\n if (!(property instanceof NavigationProperty)){\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.NavigationProperty));\n }\n return property;\n }\n}\n\n/**\n * @alpha\n * A class extending Properties allowing editing of StructProperty attributes.\n */\nexport class StructProperties extends Properties {\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\n super(ecClassType, _schemaEditor);\n }\n\n /**\n * Override to validate that the found property is a StructProperty.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n */\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\n const property = await super.getProperty<MutableStructProperty>(classKey, propertyName) as T;\n if (!(property instanceof StructProperty)){\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.StructProperty));\n }\n return property;\n }\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"Properties.js","sourceRoot":"","sources":["../../../src/Editing/Properties.ts"],"names":[],"mappings":";;;AAAA,gEAEoF;AACpF,sDAA6C;AAE7C,+CAA+C;AAQ/C,2CAAsI;AAKtI;;;GAGG;AACH,MAAa,UAAU;IACQ;IAA2C;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GAGG;AACH,MAAa,gBAAiB,SAAQ,UAAU;IAC9C,YAAmB,WAA+B,EAAE,aAAkC;QACpF,KAAK,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACgB,KAAK,CAAC,WAAW,CAAgC,QAAuB,EAAE,YAAoB;QAC/G,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,WAAW,CAAwB,QAAQ,EAAE,YAAY,CAAM,CAAC;QAC7F,IAAI,CAAC,CAAC,QAAQ,YAAY,kCAAc,CAAC,EAAC,CAAC;YACzC,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,mBAAmB,EAAE,IAAI,sBAAU,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,4BAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;QAC/J,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAjBD,4CAiBC","sourcesContent":["import { CustomAttribute, CustomAttributeContainerProps, DelayedPromiseWithProps, ECClass, ECName,\r\n EnumerationProperty, KindOfQuantity, NavigationProperty, PrimitiveProperty,\r\n PropertyCategory, SchemaItemKey, StructProperty } from \"@itwin/ecschema-metadata\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { MutableArrayProperty } from \"./Mutable/MutableArrayProperty\";\r\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\r\nimport { MutablePrimitiveOrEnumPropertyBase } from \"./Mutable/MutablePrimitiveOrEnumProperty\";\r\nimport { MutableClass } from \"./Mutable/MutableClass\";\r\nimport { MutableStructProperty } from \"./Mutable/MutableStructProperty\";\r\nimport { MutableNavigationProperty } from \"./Mutable/MutableNavigationProperty\";\r\nimport { ECClassSchemaItems } from \"./ECClasses\";\r\nimport { ClassId, CustomAttributeId, ECEditingStatus, PropertyId, PropertyTypeName, SchemaEditingError, SchemaId } from \"./Exception\";\r\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\r\n\r\ntype MutablePropertyType = MutableProperty | MutableArrayProperty | MutablePrimitiveOrEnumPropertyBase | MutableNavigationProperty | MutableStructProperty;\r\n\r\n/**\r\n * @alpha\r\n * A class allowing editing of attributes of the base Property class.\r\n */\r\nexport class Properties {\r\n public constructor(protected ecClassType: ECClassSchemaItems, protected _schemaEditor: SchemaContextEditor) {\r\n }\r\n\r\n public async setName(classKey: SchemaItemKey, propertyName: string, newPropertyName: string) {\r\n let newName: ECName;\r\n try {\r\n newName = new ECName(newPropertyName);\r\n } catch {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName),\r\n new SchemaEditingError(ECEditingStatus.InvalidECName, new PropertyId(this.ecClassType, classKey, newPropertyName)));\r\n }\r\n\r\n const existingProperty = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n\r\n const existingNewProperty = await existingProperty.class.getProperty(newPropertyName) as MutableProperty;\r\n if (existingNewProperty) {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName),\r\n new SchemaEditingError(ECEditingStatus.PropertyAlreadyExists, new PropertyId(this.ecClassType, existingNewProperty.class.key, newPropertyName)));\r\n }\r\n\r\n // Handle derived classes\r\n const derivedProperties: Array<MutableProperty> = [];\r\n const derivedClasses = await this.findDerivedClasses(existingProperty.class as MutableClass);\r\n for (const derivedClass of derivedClasses) {\r\n if (await derivedClass.getProperty(newPropertyName, true)) {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName),\r\n new SchemaEditingError(ECEditingStatus.PropertyAlreadyExists, new PropertyId(this.ecClassType, derivedClass.key, newPropertyName)));\r\n }\r\n\r\n const propertyOverride = await derivedClass.getProperty(propertyName, true) as MutableProperty;\r\n // If found the property is overridden in the derived class.\r\n if (propertyOverride)\r\n derivedProperties.push(propertyOverride);\r\n }\r\n\r\n // Re-name the overridden property in all derived classes\r\n derivedProperties.forEach((prop: MutableProperty) => {\r\n prop.setName(newName);\r\n });\r\n\r\n existingProperty.setName(newName);\r\n }\r\n\r\n /**\r\n * Sets the property description.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param description The new description to set.\r\n */\r\n public async setDescription(classKey: SchemaItemKey, propertyName: string, description: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setDescription(description);\r\n }\r\n\r\n /**\r\n * Sets the property label.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param label The new label to set.\r\n */\r\n public async setLabel(classKey: SchemaItemKey, propertyName: string, label: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setLabel(label);\r\n }\r\n\r\n /**\r\n * Sets the property isReadOnly attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param isReadOnly The new isReadOnly value.\r\n */\r\n public async setIsReadOnly(classKey: SchemaItemKey, propertyName: string, isReadOnly: boolean) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetIsReadOnly, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setIsReadOnly(isReadOnly);\r\n }\r\n\r\n /**\r\n * Sets the property priority.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param priority The new priority.\r\n */\r\n public async setPriority(classKey: SchemaItemKey, propertyName: string, priority: number) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetPriority, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setPriority(priority);\r\n }\r\n\r\n /**\r\n * Sets the property category.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param categoryKey The SchemaItemKey of the property category.\r\n */\r\n public async setCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetCategory, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n\r\n const category = await this._schemaEditor.getSchemaItem(categoryKey, PropertyCategory)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetCategory, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n\r\n property.setCategory(new DelayedPromiseWithProps<SchemaItemKey, PropertyCategory>(categoryKey, async () => category));\r\n }\r\n\r\n /**\r\n * Sets the KindOfQuantity of a property.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param kindOfQuantityKey The SchemaItemKey of the KindOfQuantity.\r\n */\r\n public async setKindOfQuantity(classKey: SchemaItemKey, propertyName: string, kindOfQuantityKey: SchemaItemKey) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetKindOfQuantity, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n\r\n const koq = await this._schemaEditor.getSchemaItem(kindOfQuantityKey, KindOfQuantity)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetKindOfQuantity, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n\r\n const currentKoq = await property.kindOfQuantity;\r\n if(currentKoq && currentKoq.persistenceUnit && koq.persistenceUnit && !currentKoq.persistenceUnit.matchesFullName(koq.persistenceUnit.fullName)) {\r\n throw new SchemaEditingError(ECEditingStatus.SetKindOfQuantity, new PropertyId(this.ecClassType, classKey, propertyName), undefined, undefined, \"KindOfQuantity can only be changed if it has the same persistence unit as the property.\");\r\n }\r\n\r\n property.setKindOfQuantity(new DelayedPromiseWithProps<SchemaItemKey, KindOfQuantity>(kindOfQuantityKey, async () => koq));\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\r\n * @param classKey The SchemaItemKey identifying the class.\r\n * @param propertyName The name of the property.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToProperty, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n\r\n property.addCustomAttribute(customAttribute);\r\n\r\n const diagnosticsIterable = Rules.validateCustomAttributeInstance(property, customAttribute);\r\n\r\n const diagnostics: AnyDiagnostic[] = [];\r\n for await (const diagnostic of diagnosticsIterable) {\r\n diagnostics.push(diagnostic);\r\n }\r\n\r\n if (diagnostics.length > 0) {\r\n this.removeCustomAttribute(property, customAttribute);\r\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToProperty, new PropertyId(this.ecClassType, classKey, propertyName),\r\n new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, property)));\r\n }\r\n }\r\n\r\n /**\r\n * Removes a CustomAttribute from a property.\r\n * @param container\r\n * @param customAttribute\r\n */\r\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\r\n assert(container.customAttributes !== undefined);\r\n const map = container.customAttributes as Map<string, CustomAttribute>;\r\n map.delete(customAttribute.className);\r\n }\r\n\r\n /**\r\n * Gets the property with the specified name from the class identified by the given key.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property to retrieve.\r\n */\r\n protected async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const mutableClass = await this.getClass(classKey);\r\n\r\n const property = await mutableClass.getProperty(propertyName, true) as T;\r\n if (property === undefined) {\r\n throw new SchemaEditingError(ECEditingStatus.PropertyNotFound, new PropertyId(mutableClass.schemaItemType as ECClassSchemaItems, classKey, propertyName));\r\n }\r\n\r\n return property;\r\n }\r\n\r\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\r\n const derivedClasses: Array<MutableClass> = [];\r\n\r\n for (const schemaItem of this._schemaEditor.schemaContext.getSchemaItems()) {\r\n if(ECClass.isECClass(schemaItem) && await schemaItem.is(mutableClass)) {\r\n if (!mutableClass.key.matches(schemaItem.key)) {\r\n derivedClasses.push(schemaItem as MutableClass);\r\n }\r\n }\r\n }\r\n\r\n return derivedClasses;\r\n }\r\n\r\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(classKey.schemaKey));\r\n\r\n const ecClass = await schema.getItem(classKey.name);\r\n if (ecClass === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new ClassId(this.ecClassType, classKey));\r\n\r\n if (ecClass.schemaItemType !== this.ecClassType){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new ClassId(this.ecClassType, classKey));\r\n }\r\n\r\n return ecClass as MutableClass;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveArrayProperty,\r\n * EnumerationArrayProperty and StructArrayProperty.\r\n */\r\nexport class ArrayProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the array property minOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minOccurs The new minOccurs value.\r\n */\r\n public async setMinOccurs(classKey: SchemaItemKey, propertyName: string, minOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMinOccurs, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMinOccurs(minOccurs);\r\n }\r\n\r\n /**\r\n * Sets the array property maxOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxOccurs The new maxOccurs value.\r\n */\r\n public async setMaxOccurs(classKey: SchemaItemKey, propertyName: string, maxOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMaxOccurs, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMaxOccurs(maxOccurs);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is an ArrayProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableArrayProperty>(classKey, propertyName) as T;\r\n if (!property.isArray()){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.ArrayProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveProperty and EnumerationProperty.\r\n */\r\nclass PrimitiveOrEnumProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the extendedTypeName attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param extendedTypeName The extended type name of the property.\r\n */\r\n public async setExtendedTypeName(classKey: SchemaItemKey, propertyName: string, extendedTypeName: string) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetExtendedTypeName, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setExtendedTypeName(extendedTypeName);\r\n }\r\n\r\n /**\r\n * Sets the minLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minLength The minimum length of the property.\r\n */\r\n public async setMinLength(classKey: SchemaItemKey, propertyName: string, minLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMinLength, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMinLength(minLength);\r\n }\r\n\r\n /**\r\n * Sets the maxLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxLength The maximum length of the property.\r\n */\r\n public async setMaxLength(classKey: SchemaItemKey, propertyName: string, maxLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMaxLength, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMaxLength(maxLength);\r\n }\r\n\r\n /**\r\n * Sets the minValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minValue The minimum value of the property.\r\n */\r\n public async setMinValue(classKey: SchemaItemKey, propertyName: string, minValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMinValue, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMinValue(minValue);\r\n }\r\n\r\n /**\r\n * Sets the maxValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxValue The maximum value of the property.\r\n */\r\n public async setMaxValue(classKey: SchemaItemKey, propertyName: string, maxValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMaxValue, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMaxValue(maxValue);\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of PrimitiveProperty attributes.\r\n */\r\nexport class PrimitiveProperties extends PrimitiveOrEnumProperties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a PrimitiveProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof PrimitiveProperty)){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.PrimitiveProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of EnumerationProperty attributes.\r\n */\r\nexport class EnumerationProperties extends PrimitiveOrEnumProperties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a EnumerationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof EnumerationProperty)){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.EnumerationProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of NavigationProperties attributes.\r\n */\r\nexport class NavigationProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a NavigationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableNavigationProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof NavigationProperty)){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.NavigationProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of StructProperty attributes.\r\n */\r\nexport class StructProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a StructProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableStructProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof StructProperty)){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.StructProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyCategories.js","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA6H;AAE7H,+EAA4E;AAC5E,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,yBAAW;IACjD,IAAuB,aAAa;QAClC,OAAO,oCAAgB,CAAC;IAC1B,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAgB,EAAE,YAAqB;QAC7F,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAmB,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAA4B,CAAC;YAC/L,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACtC,IAAI,YAAY;gBACd,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEhD,OAAO,eAAe,CAAC,GAAG,CAAC;QAC7B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,qBAA4C;QAC7F,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC,CAAC;YAC5K,OAAO,eAAe,CAAC,GAAG,CAAC;QAC7B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,qBAAqB,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5J,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,eAA8B,EAAE,QAAgB;QACvE,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,iDAAuB,CAAC,CAAC;YAC5F,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,2BAA2B,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACvI,CAAC;IACH,CAAC;CACF;AAvCD,gDAuCC","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 { PropertyCategory, PropertyCategoryProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutablePropertyCategory } from \"./Mutable/MutablePropertyCategory\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Property Category.\n */\nexport class PropertyCategories extends SchemaItems {\n protected override get itemTypeClass(): typeof PropertyCategory {\n return PropertyCategory;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.PropertyCategory, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newPropCategory = await this.createSchemaItem<PropertyCategory>(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), name) as MutablePropertyCategory;\n newPropCategory.setPriority(priority);\n if (displayLabel)\n newPropCategory.setDisplayLabel(displayLabel);\n\n return newPropCategory.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemKey> {\n try {\n const newPropCategory = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), propertyCategoryProps);\n return newPropCategory.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, propertyCategoryProps.name!, schemaKey), e);\n }\n }\n\n public async setPriority(propCategoryKey: SchemaItemKey, priority: number): Promise<void> {\n try {\n const propertyCategory = await this.getSchemaItem(propCategoryKey, MutablePropertyCategory);\n propertyCategory.setPriority(priority);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetPropertyCategoryPriority, new SchemaItemId(this.schemaItemType, propCategoryKey), e);\n }\n }\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AAM,EAAE,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC,CAAC;YAC5K,OAAO,eAAe,CAAC,GAAG,CAAC;QAC7B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,qBAAqB,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5J,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,eAA8B,EAAE,QAAgB;QACvE,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,iDAAuB,CAAC,CAAC;YAC5F,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,2BAA2B,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACvI,CAAC;IACH,CAAC;CACF;AAvCD,gDAuCC","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 { PropertyCategory, PropertyCategoryProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutablePropertyCategory } from \"./Mutable/MutablePropertyCategory\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Property Category.\r\n */\r\nexport class PropertyCategories extends SchemaItems {\r\n protected override get itemTypeClass(): typeof PropertyCategory {\r\n return PropertyCategory;\r\n }\r\n\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.PropertyCategory, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemKey> {\r\n try {\r\n const newPropCategory = await this.createSchemaItem<PropertyCategory>(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), name) as MutablePropertyCategory;\r\n newPropCategory.setPriority(priority);\r\n if (displayLabel)\r\n newPropCategory.setDisplayLabel(displayLabel);\r\n\r\n return newPropCategory.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemKey> {\r\n try {\r\n const newPropCategory = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), propertyCategoryProps);\r\n return newPropCategory.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, propertyCategoryProps.name!, schemaKey), e);\r\n }\r\n }\r\n\r\n public async setPriority(propCategoryKey: SchemaItemKey, priority: number): Promise<void> {\r\n try {\r\n const propertyCategory = await this.getSchemaItem(propCategoryKey, MutablePropertyCategory);\r\n propertyCategory.setPriority(priority);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyCategoryPriority, new SchemaItemId(this.schemaItemType, propCategoryKey), e);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClasses.js","sourceRoot":"","sources":["../../../src/Edit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1D,kBAAkB,GAAG,KAAK,CAAC,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;YAC1E,eAAe,GAAG,wBAAwB,CAAC,GAAG,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,kBAAkB,GAAG,KAAK,CAAC,8BAA8B,CAAC,wBAAwB,CAAC,CAAC;YACpF,eAAe,GAAG,wBAAwB,CAAC,iBAAiB,CAAC,GAAG,CAAC;QACnE,CAAC;QAED,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,IAAI,KAAK,EAAE,MAAM,UAAU,IAAI,kBAAkB,EAAE,CAAC;YAClD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,IAAI,wBAAwB,YAAY,qCAAiB,EAAE,CAAC;gBAC1D,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,aAAa,EAAE,IAAI,mBAAO,CAAC,kCAAc,CAAC,iBAAiB,EAAE,eAAe,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;YACtJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,aAAa,EAAE,IAAI,oCAAwB,CAAC,wBAAwB,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;YAC9I,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAlPD,kDAkPC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n CustomAttribute, DelayedPromiseWithProps, ECClass, ECClassModifier, EntityClass, LazyLoadedRelationshipConstraintClass, Mixin, NavigationPropertyProps,\n RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaItemType,\n SchemaKey, StrengthDirection, StrengthType,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableRelationshipClass, MutableRelationshipConstraint } from \"./Mutable/MutableRelationshipClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { AnyDiagnostic, RelationshipConstraintDiagnostic, SchemaItemDiagnostic } from \"../Validation/Diagnostic\";\nimport { NavigationProperties } from \"./Properties\";\nimport { ClassId, CustomAttributeId, ECEditingStatus, RelationshipConstraintId, SchemaEditingError } from \"./Exception\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type RelationshipClass.\n */\nexport class RelationshipClasses extends ECClasses {\n protected override get itemTypeClass(): typeof RelationshipClass {\n return RelationshipClass;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.RelationshipClass, schemaEditor);\n }\n\n /**\n * Allows access for editing of NavigationProperty attributes.\n */\n public readonly navigationProperties = new NavigationProperties(this.schemaItemType, this.schemaEditor);\n\n /**\n * Creates a RelationshipClass.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param name The name of the new class.\n * @param modifier The ECClassModifier of the new class.\n * @param strength The relationship StrengthType of the class.\n * @param StrengthDirection The relationship StrengthDirection of the class.\n * @param baseClassKey An optional SchemaItemKey that specifies the base relationship class.\n */\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, strength: StrengthType, direction: StrengthDirection, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<RelationshipClass>(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), name, baseClassKey, modifier) as MutableRelationshipClass;\n\n newClass.setStrength(strength);\n newClass.setStrengthDirection(direction);\n\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n /**\n * Sets the source RelationshipConstraint on the relationship.\n * @param relationshipKey The SchemaItemKey for the relationship.\n * @param source The RelationshipConstraint to add.\n */\n public async setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<void> {\n const relationship = await this.getSchemaItem(relationshipKey, MutableRelationshipClass)\n .catch((e) => {\n throw new SchemaEditingError(ECEditingStatus.SetSourceConstraint, new ClassId(this.schemaItemType, relationshipKey), e);\n });\n\n relationship.setSourceConstraint(source);\n }\n\n /**\n * Sets the target RelationshipConstraint on the relationship.\n * @param relationshipKey The SchemaItemKey for the relationship.\n * @param target The RelationshipConstraint to add.\n */\n public async setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<void> {\n const relationship = await this.getSchemaItem(relationshipKey, MutableRelationshipClass)\n .catch((e) => {\n throw new SchemaEditingError(ECEditingStatus.SetTargetConstraint, new ClassId(this.schemaItemType, relationshipKey), e);\n });\n\n relationship.setTargetConstraint(target);\n }\n\n /**\n * Creates a RelationshipClass through a RelationshipClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, relationshipProps: RelationshipClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), relationshipProps);\n\n await newClass.source.fromJSON(relationshipProps.source);\n await newClass.target.fromJSON(relationshipProps.target);\n\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, relationshipProps.name!, schemaKey), e);\n }\n }\n\n /**\n * Sets the base class of a RelationshipClass.\n * @param relationshipKey The SchemaItemKey of the RelationshipClass.\n * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.\n */\n public override async setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<void> {\n const relClass = await this.schemaEditor.schemaContext.getSchemaItem(itemKey, RelationshipClass)\n .catch((e) => {\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(this.schemaItemType, itemKey), e);\n });\n const baseClass = relClass?.baseClass;\n\n await super.setBaseClass(itemKey, baseClassKey);\n\n try {\n await this.validate(relClass!);\n } catch(e: any) {\n await (relClass! as ECClass as MutableClass).setBaseClass(baseClass);\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(SchemaItemType.RelationshipClass, itemKey), e);\n }\n }\n\n public async createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void> {\n try {\n const relationshipClass = await this.getSchemaItem(relationshipKey, MutableRelationshipClass);\n await relationshipClass.createNavigationProperty(name, relationship, direction);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationProperty, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), e);\n }\n }\n\n /**\n * Creates a Navigation Property through a NavigationPropertyProps.\n * @param classKey a SchemaItemKey of the Relationship Class that will house the new property.\n * @param navigationProps a json object that will be used to populate the new Navigation Property.\n */\n public async createNavigationPropertyFromProps(relationshipKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void> {\n try {\n const relationshipClass = await this.getSchemaItem(relationshipKey, MutableRelationshipClass);\n const property = await relationshipClass.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\n await property.fromJSON(navigationProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationPropertyFromProps, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), e);\n }\n }\n\n public async setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.setMultiplicity(multiplicity);\n }\n\n public async setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.setPolymorphic(polymorphic);\n }\n\n public async setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.setRelationshipEnd(relationshipEnd);\n }\n\n public async setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<void> {\n const existing: LazyLoadedRelationshipConstraintClass | undefined = constraint.abstractConstraint;\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n\n if (undefined === abstractConstraint) {\n mutableConstraint.setAbstractConstraint(undefined);\n } else {\n mutableConstraint.setAbstractConstraint(new DelayedPromiseWithProps(abstractConstraint.key, async () => abstractConstraint));\n }\n\n try {\n await this.validate(constraint.relationshipClass);\n } catch(e: any){\n mutableConstraint.setAbstractConstraint(existing);\n throw new SchemaEditingError(ECEditingStatus.SetAbstractConstraint, new RelationshipConstraintId(constraint), e);\n }\n\n try {\n await this.validate(constraint);\n } catch(e: any){\n mutableConstraint.setAbstractConstraint(existing);\n throw new SchemaEditingError(ECEditingStatus.SetAbstractConstraint, new RelationshipConstraintId(constraint), e);\n }\n }\n\n public async addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.addClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\n\n try {\n await this.validate(constraint.relationshipClass);\n } catch(e: any){\n mutableConstraint.removeClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\n throw new SchemaEditingError(ECEditingStatus.AddConstraintClass, new RelationshipConstraintId(constraint), e);\n }\n\n try {\n await this.validate(constraint);\n } catch(e: any){\n mutableConstraint.removeClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\n throw new SchemaEditingError(ECEditingStatus.AddConstraintClass, new RelationshipConstraintId(constraint), e);\n }\n }\n\n public async removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.removeClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\n\n try{\n await this.validate(constraint);\n } catch(e: any) {\n mutableConstraint.addClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\n throw new SchemaEditingError(ECEditingStatus.RemoveConstraintClass, new RelationshipConstraintId(constraint), e);\n }\n }\n\n public async addCustomAttributeToConstraint(constraint: RelationshipConstraint, customAttribute: CustomAttribute): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.addCustomAttribute(customAttribute);\n\n const diagnosticIterable = Rules.validateCustomAttributeInstance(constraint, customAttribute);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of diagnosticIterable) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeCustomAttribute(constraint, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToConstraint, new RelationshipConstraintId(constraint),\n new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, constraint), undefined, diagnostics));\n }\n }\n\n private async validate(relationshipOrConstraint: RelationshipClass | RelationshipConstraint): Promise<void> {\n let diagnosticIterable: AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> | AsyncIterable<RelationshipConstraintDiagnostic<any[]>>;\n let relationshipKey: SchemaItemKey | string;\n\n if (relationshipOrConstraint instanceof RelationshipClass) {\n diagnosticIterable = Rules.validateRelationship(relationshipOrConstraint);\n relationshipKey = relationshipOrConstraint.key;\n } else {\n diagnosticIterable = Rules.validateRelationshipConstraint(relationshipOrConstraint);\n relationshipKey = relationshipOrConstraint.relationshipClass.key;\n }\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of diagnosticIterable) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n if (relationshipOrConstraint instanceof RelationshipClass) {\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), undefined, diagnostics);\n } else {\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new RelationshipConstraintId(relationshipOrConstraint), undefined, diagnostics);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RelationshipClasses.js","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAIkC;AAElC,2CAAwC;AACxC,iFAA6G;AAC7G,+CAA+C;AAE/C,6CAAoD;AACpD,2CAAwH;AAGxH;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,qBAAS;IAChD,IAAuB,aAAa;QAClC,OAAO,qCAAiB,CAAC;IAC3B,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACa,oBAAoB,GAAG,IAAI,iCAAoB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAExG;;;;;;;;OAQG;IACI,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAyB,EAAE,QAAsB,EAAE,SAA4B,EAAE,YAA4B;QACnK,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAoB,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,CAA6B,CAAC;YAE9M,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC/B,QAAQ,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;YAEzC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Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport {\r\n CustomAttribute, DelayedPromiseWithProps, ECClass, ECClassModifier, EntityClass, LazyLoadedRelationshipConstraintClass, Mixin, NavigationPropertyProps,\r\n RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaItemType,\r\n SchemaKey, StrengthDirection, StrengthType,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableRelationshipClass, MutableRelationshipConstraint } from \"./Mutable/MutableRelationshipClass\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { AnyDiagnostic, RelationshipConstraintDiagnostic, SchemaItemDiagnostic } from \"../Validation/Diagnostic\";\r\nimport { NavigationProperties } from \"./Properties\";\r\nimport { ClassId, CustomAttributeId, ECEditingStatus, RelationshipConstraintId, SchemaEditingError } from \"./Exception\";\r\nimport { MutableClass } from \"./Mutable/MutableClass\";\r\n\r\n/**\r\n * @alpha\r\n * A class extending ECClasses allowing you to create schema items of type RelationshipClass.\r\n */\r\nexport class RelationshipClasses extends ECClasses {\r\n protected override get itemTypeClass(): typeof RelationshipClass {\r\n return RelationshipClass;\r\n }\r\n\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.RelationshipClass, schemaEditor);\r\n }\r\n\r\n /**\r\n * Allows access for editing of NavigationProperty attributes.\r\n */\r\n public readonly navigationProperties = new NavigationProperties(this.schemaItemType, this.schemaEditor);\r\n\r\n /**\r\n * Creates a RelationshipClass.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param name The name of the new class.\r\n * @param modifier The ECClassModifier of the new class.\r\n * @param strength The relationship StrengthType of the class.\r\n * @param StrengthDirection The relationship StrengthDirection of the class.\r\n * @param baseClassKey An optional SchemaItemKey that specifies the base relationship class.\r\n */\r\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, strength: StrengthType, direction: StrengthDirection, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\r\n try {\r\n const newClass = await this.createClass<RelationshipClass>(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), name, baseClassKey, modifier) as MutableRelationshipClass;\r\n\r\n newClass.setStrength(strength);\r\n newClass.setStrengthDirection(direction);\r\n\r\n return newClass.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new ClassId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the source RelationshipConstraint on the relationship.\r\n * @param relationshipKey The SchemaItemKey for the relationship.\r\n * @param source The RelationshipConstraint to add.\r\n */\r\n public async setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<void> {\r\n const relationship = await this.getSchemaItem(relationshipKey, MutableRelationshipClass)\r\n .catch((e) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetSourceConstraint, new ClassId(this.schemaItemType, relationshipKey), e);\r\n });\r\n\r\n relationship.setSourceConstraint(source);\r\n }\r\n\r\n /**\r\n * Sets the target RelationshipConstraint on the relationship.\r\n * @param relationshipKey The SchemaItemKey for the relationship.\r\n * @param target The RelationshipConstraint to add.\r\n */\r\n public async setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<void> {\r\n const relationship = await this.getSchemaItem(relationshipKey, MutableRelationshipClass)\r\n .catch((e) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetTargetConstraint, new ClassId(this.schemaItemType, relationshipKey), e);\r\n });\r\n\r\n relationship.setTargetConstraint(target);\r\n }\r\n\r\n /**\r\n * Creates a RelationshipClass through a RelationshipClassProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, relationshipProps: RelationshipClassProps): Promise<SchemaItemKey> {\r\n try {\r\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), relationshipProps);\r\n\r\n await newClass.source.fromJSON(relationshipProps.source);\r\n await newClass.target.fromJSON(relationshipProps.target);\r\n\r\n return newClass.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, relationshipProps.name!, schemaKey), e);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the base class of a RelationshipClass.\r\n * @param relationshipKey The SchemaItemKey of the RelationshipClass.\r\n * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.\r\n */\r\n public override async setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<void> {\r\n const relClass = await this.schemaEditor.schemaContext.getSchemaItem(itemKey, RelationshipClass)\r\n .catch((e) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(this.schemaItemType, itemKey), e);\r\n });\r\n const baseClass = relClass?.baseClass;\r\n\r\n await super.setBaseClass(itemKey, baseClassKey);\r\n\r\n try {\r\n await this.validate(relClass!);\r\n } catch(e: any) {\r\n await (relClass! as ECClass as MutableClass).setBaseClass(baseClass);\r\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(SchemaItemType.RelationshipClass, itemKey), e);\r\n }\r\n }\r\n\r\n public async createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void> {\r\n try {\r\n const relationshipClass = await this.getSchemaItem(relationshipKey, MutableRelationshipClass);\r\n await relationshipClass.createNavigationProperty(name, relationship, direction);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationProperty, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), e);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a Navigation Property through a NavigationPropertyProps.\r\n * @param classKey a SchemaItemKey of the Relationship Class that will house the new property.\r\n * @param navigationProps a json object that will be used to populate the new Navigation Property.\r\n */\r\n public async createNavigationPropertyFromProps(relationshipKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void> {\r\n try {\r\n const relationshipClass = await this.getSchemaItem(relationshipKey, MutableRelationshipClass);\r\n const property = await relationshipClass.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\r\n await property.fromJSON(navigationProps);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationPropertyFromProps, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), e);\r\n }\r\n }\r\n\r\n public async setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<void> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.setMultiplicity(multiplicity);\r\n }\r\n\r\n public async setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<void> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.setPolymorphic(polymorphic);\r\n }\r\n\r\n public async setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<void> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.setRelationshipEnd(relationshipEnd);\r\n }\r\n\r\n public async setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<void> {\r\n const existing: LazyLoadedRelationshipConstraintClass | undefined = constraint.abstractConstraint;\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n\r\n if (undefined === abstractConstraint) {\r\n mutableConstraint.setAbstractConstraint(undefined);\r\n } else {\r\n mutableConstraint.setAbstractConstraint(new DelayedPromiseWithProps(abstractConstraint.key, async () => abstractConstraint));\r\n }\r\n\r\n try {\r\n await this.validate(constraint.relationshipClass);\r\n } catch(e: any){\r\n mutableConstraint.setAbstractConstraint(existing);\r\n throw new SchemaEditingError(ECEditingStatus.SetAbstractConstraint, new RelationshipConstraintId(constraint), e);\r\n }\r\n\r\n try {\r\n await this.validate(constraint);\r\n } catch(e: any){\r\n mutableConstraint.setAbstractConstraint(existing);\r\n throw new SchemaEditingError(ECEditingStatus.SetAbstractConstraint, new RelationshipConstraintId(constraint), e);\r\n }\r\n }\r\n\r\n public async addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.addClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\r\n\r\n try {\r\n await this.validate(constraint.relationshipClass);\r\n } catch(e: any){\r\n mutableConstraint.removeClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\r\n throw new SchemaEditingError(ECEditingStatus.AddConstraintClass, new RelationshipConstraintId(constraint), e);\r\n }\r\n\r\n try {\r\n await this.validate(constraint);\r\n } catch(e: any){\r\n mutableConstraint.removeClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\r\n throw new SchemaEditingError(ECEditingStatus.AddConstraintClass, new RelationshipConstraintId(constraint), e);\r\n }\r\n }\r\n\r\n public async removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.removeClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\r\n\r\n try{\r\n await this.validate(constraint);\r\n } catch(e: any) {\r\n mutableConstraint.addClass(new DelayedPromiseWithProps(ecClass.key, async () => ecClass));\r\n throw new SchemaEditingError(ECEditingStatus.RemoveConstraintClass, new RelationshipConstraintId(constraint), e);\r\n }\r\n }\r\n\r\n public async addCustomAttributeToConstraint(constraint: RelationshipConstraint, customAttribute: CustomAttribute): Promise<void> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.addCustomAttribute(customAttribute);\r\n\r\n const diagnosticIterable = Rules.validateCustomAttributeInstance(constraint, customAttribute);\r\n\r\n const diagnostics: AnyDiagnostic[] = [];\r\n for await (const diagnostic of diagnosticIterable) {\r\n diagnostics.push(diagnostic);\r\n }\r\n\r\n if (diagnostics.length > 0) {\r\n this.removeCustomAttribute(constraint, customAttribute);\r\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToConstraint, new RelationshipConstraintId(constraint),\r\n new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, constraint), undefined, diagnostics));\r\n }\r\n }\r\n\r\n private async validate(relationshipOrConstraint: RelationshipClass | RelationshipConstraint): Promise<void> {\r\n let diagnosticIterable: AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> | AsyncIterable<RelationshipConstraintDiagnostic<any[]>>;\r\n let relationshipKey: SchemaItemKey | string;\r\n\r\n if (relationshipOrConstraint instanceof RelationshipClass) {\r\n diagnosticIterable = Rules.validateRelationship(relationshipOrConstraint);\r\n relationshipKey = relationshipOrConstraint.key;\r\n } else {\r\n diagnosticIterable = Rules.validateRelationshipConstraint(relationshipOrConstraint);\r\n relationshipKey = relationshipOrConstraint.relationshipClass.key;\r\n }\r\n\r\n const diagnostics: AnyDiagnostic[] = [];\r\n for await (const diagnostic of diagnosticIterable) {\r\n diagnostics.push(diagnostic);\r\n }\r\n\r\n if (diagnostics.length > 0) {\r\n if (relationshipOrConstraint instanceof RelationshipClass) {\r\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), undefined, diagnostics);\r\n } else {\r\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new RelationshipConstraintId(relationshipOrConstraint), undefined, diagnostics);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItems.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yB,CAAuB,SAAoB,EAAE,IAAoB,EAAE,MAA2B,EAAE,KAAsB;QAC7J,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;YAC1B,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,0BAA0B,EAAE,IAAI,wBAAY,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;QAElH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAI,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE9B,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAxGD,kCAwGC","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 { ECSchemaError, ECSchemaStatus, SchemaItem, SchemaItemKey, SchemaItemProps, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\nimport { MutableSchemaItem } from \"./Mutable/MutableSchemaItem\";\n\nexport type CreateSchemaItem<T extends SchemaItem> = (schema: MutableSchema) => (name: string, ...args: any[]) => Promise<T>;\nexport type CreateSchemaItemFromProps<T extends SchemaItem> = (props: SchemaItemProps, ...args: any[]) => Promise<T>;\n\n/**\n * @internal\n * A class allowing you to edit the schema item base class.\n */\nexport abstract class SchemaItems {\n protected schemaItemType: SchemaItemType;\n protected schemaEditor: SchemaContextEditor;\n\n protected abstract get itemTypeClass(): typeof SchemaItem;\n\n public constructor(schemaItemType: SchemaItemType, schemaEditor: SchemaContextEditor) {\n this.schemaItemType = schemaItemType;\n this.schemaEditor = schemaEditor;\n }\n\n /**\n * Sets the name of the SchemaItem.\n * @param itemKey The SchemaItemKey of the SchemaItem.\n * @param name The new name of the SchemaItem.\n * @throws ECSchemaError if `name` does not meet the criteria for a valid EC name\n */\n public async setName(itemKey: SchemaItemKey, name: string): Promise<SchemaItemKey> {\n try {\n const schema = await this.getSchema(itemKey.schemaKey);\n const ecClass = await schema.getItem(name, this.itemTypeClass);\n if (ecClass !== undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(this.schemaItemType, name, schema.schemaKey));\n\n const mutableItem = await this.getSchemaItem(itemKey, this.itemTypeClass) as MutableSchemaItem;\n\n const existingName = itemKey.name;\n mutableItem.setName(name);\n\n // Must reset in schema item map\n await schema.deleteSchemaItem(existingName);\n schema.addItem(mutableItem);\n return mutableItem.key;\n } catch(e: any) {\n if (e instanceof ECSchemaError && e.errorNumber === ECSchemaStatus.InvalidECName) {\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey),\n new SchemaEditingError(ECEditingStatus.InvalidECName, new SchemaItemId(this.schemaItemType, itemKey)));\n }\n\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey), e);\n }\n }\n\n /**\n * Sets the SchemaItem description.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param description The new description to set.\n */\n public async setDescription(schemaItemKey: SchemaItemKey, description: string) {\n const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n (item as MutableSchemaItem).setDescription(description);\n }\n\n /**\n * Sets the SchemaItem display label.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param label The new label to set.\n */\n public async setDisplayLabel(schemaItemKey: SchemaItemKey, label: string) {\n const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n (item as MutableSchemaItem).setDisplayLabel(label);\n }\n\n protected async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\n const schema = await this.schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema;\n }\n\n protected async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T>> {\n return this.schemaEditor.getSchemaItem(schemaItemKey, itemConstructor);\n }\n\n protected async createSchemaItem<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, ...args: any[]): Promise<T> {\n const schema = await this.getSchema(schemaKey);\n try {\n const boundCreate = create(schema);\n return await boundCreate(name, ...args);\n } catch (e) {\n if (e instanceof ECSchemaError && e.errorNumber === ECSchemaStatus.DuplicateItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(type, name, schema.schemaKey));\n } else {\n throw new Error(`Failed to create class ${name} in schema ${schema.fullName}.`);\n }\n }\n }\n\n protected async createSchemaItemFromProps<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, props: SchemaItemProps): Promise<T> {\n if (props.name === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameNotSpecified, new SchemaItemId(type, \"\", schemaKey));\n\n const newItem = await this.createSchemaItem<T>(schemaKey, type, create, props.name);\n await newItem.fromJSON(props);\n\n return newItem;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAgJ;AAEhJ,2CAA0F;AAO1F;;;GAGG;AACH,MAAsB,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BAA0B,EAAE,IAAI,wBAAY,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;QAElH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAI,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE9B,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAxGD,kCAwGC","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 { ECSchemaError, ECSchemaStatus, SchemaItem, SchemaItemKey, SchemaItemProps, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\r\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\r\nimport { MutableSchemaItem } from \"./Mutable/MutableSchemaItem\";\r\n\r\nexport type CreateSchemaItem<T extends SchemaItem> = (schema: MutableSchema) => (name: string, ...args: any[]) => Promise<T>;\r\nexport type CreateSchemaItemFromProps<T extends SchemaItem> = (props: SchemaItemProps, ...args: any[]) => Promise<T>;\r\n\r\n/**\r\n * @internal\r\n * A class allowing you to edit the schema item base class.\r\n */\r\nexport abstract class SchemaItems {\r\n protected schemaItemType: SchemaItemType;\r\n protected schemaEditor: SchemaContextEditor;\r\n\r\n protected abstract get itemTypeClass(): typeof SchemaItem;\r\n\r\n public constructor(schemaItemType: SchemaItemType, schemaEditor: SchemaContextEditor) {\r\n this.schemaItemType = schemaItemType;\r\n this.schemaEditor = schemaEditor;\r\n }\r\n\r\n /**\r\n * Sets the name of the SchemaItem.\r\n * @param itemKey The SchemaItemKey of the SchemaItem.\r\n * @param name The new name of the SchemaItem.\r\n * @throws ECSchemaError if `name` does not meet the criteria for a valid EC name\r\n */\r\n public async setName(itemKey: SchemaItemKey, name: string): Promise<SchemaItemKey> {\r\n try {\r\n const schema = await this.getSchema(itemKey.schemaKey);\r\n const ecClass = await schema.getItem(name, this.itemTypeClass);\r\n if (ecClass !== undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(this.schemaItemType, name, schema.schemaKey));\r\n\r\n const mutableItem = await this.getSchemaItem(itemKey, this.itemTypeClass) as MutableSchemaItem;\r\n\r\n const existingName = itemKey.name;\r\n mutableItem.setName(name);\r\n\r\n // Must reset in schema item map\r\n await schema.deleteSchemaItem(existingName);\r\n schema.addItem(mutableItem);\r\n return mutableItem.key;\r\n } catch(e: any) {\r\n if (e instanceof ECSchemaError && e.errorNumber === ECSchemaStatus.InvalidECName) {\r\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey),\r\n new SchemaEditingError(ECEditingStatus.InvalidECName, new SchemaItemId(this.schemaItemType, itemKey)));\r\n }\r\n\r\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey), e);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the SchemaItem description.\r\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\r\n * @param description The new description to set.\r\n */\r\n public async setDescription(schemaItemKey: SchemaItemKey, description: string) {\r\n const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\r\n });\r\n (item as MutableSchemaItem).setDescription(description);\r\n }\r\n\r\n /**\r\n * Sets the SchemaItem display label.\r\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\r\n * @param label The new label to set.\r\n */\r\n public async setDisplayLabel(schemaItemKey: SchemaItemKey, label: string) {\r\n const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\r\n });\r\n (item as MutableSchemaItem).setDisplayLabel(label);\r\n }\r\n\r\n protected async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\r\n const schema = await this.schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\r\n\r\n return schema;\r\n }\r\n\r\n protected async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T>> {\r\n return this.schemaEditor.getSchemaItem(schemaItemKey, itemConstructor);\r\n }\r\n\r\n protected async createSchemaItem<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, ...args: any[]): Promise<T> {\r\n const schema = await this.getSchema(schemaKey);\r\n try {\r\n const boundCreate = create(schema);\r\n return await boundCreate(name, ...args);\r\n } catch (e) {\r\n if (e instanceof ECSchemaError && e.errorNumber === ECSchemaStatus.DuplicateItem) {\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(type, name, schema.schemaKey));\r\n } else {\r\n throw new Error(`Failed to create class ${name} in schema ${schema.fullName}.`);\r\n }\r\n }\r\n }\r\n\r\n protected async createSchemaItemFromProps<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, props: SchemaItemProps): Promise<T> {\r\n if (props.name === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameNotSpecified, new SchemaItemId(type, \"\", schemaKey));\r\n\r\n const newItem = await this.createSchemaItem<T>(schemaKey, type, create, props.name);\r\n await newItem.fromJSON(props);\r\n\r\n return newItem;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1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AAE,WAAW,CAAC,CAAC;YACtJ,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC;CACF;AAnCD,0BAmCC","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 { SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableStructClass } from \"./Mutable/MutableClass\";\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\n\n/**\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\n */\nexport class Structs extends ECClasses {\n protected override get itemTypeClass(): typeof StructClass {\n return StructClass;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.StructClass, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<StructClass>(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), name, baseClassKey) as MutableStructClass;\n\n if (displayLabel)\n newClass.setDisplayLabel(displayLabel);\n\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\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<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), structProps);\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, structProps.name!, schemaKey), e);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAmH;AAEnH,2CAAwC;AAExC,2CAA2E;AAE3E;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,IAAuB,aAAa;QAClC,OAAO,+BAAW,CAAC;IACrB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,YAA4B;QACzG,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAc,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,CAAuB,CAAC;YAElL,IAAI,YAAY;gBACd,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEzC,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAA6B;QAC9E,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;YACtJ,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC;CACF;AAnCD,0BAmCC","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 { SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableStructClass } from \"./Mutable/MutableClass\";\r\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\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 protected override get itemTypeClass(): typeof StructClass {\r\n return StructClass;\r\n }\r\n\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.StructClass, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\r\n try {\r\n const newClass = await this.createClass<StructClass>(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), name, baseClassKey) as MutableStructClass;\r\n\r\n if (displayLabel)\r\n newClass.setDisplayLabel(displayLabel);\r\n\r\n return newClass.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new ClassId(this.schemaItemType, name, schemaKey), e);\r\n }\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<SchemaItemKey> {\r\n try {\r\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), structProps);\r\n return newClass.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, structProps.name!, schemaKey), e);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiH;AAGjH,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,WAAY,SAAQ,yBAAW;IAC1C,IAAuB,aAAa;QAClC,OAAO,8BAAU,CAAC;IACpB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAE3E,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAsB,CAAC;YAE3K,IAAI,YAAY;gBACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAE9C,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC;YAC9J,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;CACF;AA/BD,kCA+BC","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 { SchemaItemKey, SchemaItemType, SchemaKey, UnitSystem, UnitSystemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type UnitSystems.\n */\nexport class UnitSystems extends SchemaItems {\n protected override get itemTypeClass(): typeof UnitSystem {\n return UnitSystem;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.UnitSystem, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey> {\n\n try {\n const newUnitSystem = await this.createSchemaItem<UnitSystem>(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), name) as MutableUnitSystem;\n\n if (displayLabel)\n newUnitSystem.setDisplayLabel(displayLabel);\n\n return newUnitSystem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey> {\n try {\n const newUnitSystem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), unitSystemProps);\n return newUnitSystem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitSystemProps.name!, schemaKey), e);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiH;AAGjH,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,WAAY,SAAQ,yBAAW;IAC1C,IAAuB,aAAa;Q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,CAAC;QACtJ,CAAC;IACH,CAAC;CACF;AA/BD,kCA+BC","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 { SchemaItemKey, SchemaItemType, SchemaKey, UnitSystem, UnitSystemProps } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\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 extends SchemaItems {\r\n protected override get itemTypeClass(): typeof UnitSystem {\r\n return UnitSystem;\r\n }\r\n\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.UnitSystem, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey> {\r\n\r\n try {\r\n const newUnitSystem = await this.createSchemaItem<UnitSystem>(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), name) as MutableUnitSystem;\r\n\r\n if (displayLabel)\r\n newUnitSystem.setDisplayLabel(displayLabel);\r\n\r\n return newUnitSystem.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey> {\r\n try {\r\n const newUnitSystem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), unitSystemProps);\r\n return newUnitSystem.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitSystemProps.name!, schemaKey), e);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAgK;AAGhK,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,KAAM,SAAQ,yBAAW;IACpC,IAAuB,aAAa;QAClC,OAAO,wBAAI,CAAC;IACd,CAAC;IAED,6CAA6C;IAC7C,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAyB,EAAE,UAAyB,EAAE,YAAqB;QACrJ,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAO,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAgB,CAAC;YAEnJ,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,8BAAU,CAAC,CAAC;YACxE,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE5H,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,8BAAU,CAAC,CAAC;YACxE,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE5H,MAAM,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAExC,IAAI,YAAY;gBACd,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAExC,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA8B;QAC/E,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;YAC5I,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAChJ,CAAC;IACH,CAAC;CACF;AAvCD,sBAuCC","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, SchemaItemUnitProps, SchemaKey, Unit, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Unit.\n */\nexport class Units extends SchemaItems {\n protected override get itemTypeClass(): typeof Unit {\n return Unit;\n }\n\n // TODO: Add more setters for all attributes.\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Unit, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItem<Unit>(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name) as MutableUnit;\n\n const phenomenonItem = await this.getSchemaItem(phenomenon, Phenomenon);\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\n\n const unitSystemItem = await this.getSchemaItem(unitSystem, UnitSystem);\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 newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts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YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA8B;QAC/E,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;YAC5I,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAChJ,CAAC;IACH,CAAC;CACF;AAvCD,sBAuCC","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, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, Unit, UnitSystem } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\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 extends SchemaItems {\r\n protected override get itemTypeClass(): typeof Unit {\r\n return Unit;\r\n }\r\n\r\n // TODO: Add more setters for all attributes.\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.Unit, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\r\n try {\r\n const newUnit = await this.createSchemaItem<Unit>(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name) as MutableUnit;\r\n\r\n const phenomenonItem = await this.getSchemaItem(phenomenon, Phenomenon);\r\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\r\n\r\n const unitSystemItem = await this.getSchemaItem(unitSystem, UnitSystem);\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 newUnit.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey> {\r\n try {\r\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);\r\n return newUnit.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;AAgBA,kCA+BC;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kBAAkB,CAAC,OAA2B,EAAE,IAAa;IACpE,OAAO,KAAK,EAAE,OAAsB,EAAE,YAA2B,EAAE,EAAE;QACnE,QAAQ,IAAI,CAAC,cAAc,EAAE,CAAC;YAC5B,KAAK,kCAAc,CAAC,oBAAoB,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACrH,KAAK,kCAAc,CAAC,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACpG,KAAK,kCAAc,CAAC,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC5F,KAAK,kCAAc,CAAC,iBAAiB,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC/G,KAAK,kCAAc,CAAC,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACrG,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,IAAI,qBAAqB,CAAC,CAAC;IAC9E,CAAC,CAAC;AACJ,CAAC","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*--------------------------------------------------------------------------------------------*/\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\nimport { AnyClassItemDifference } from \"../Differencing/SchemaDifference\";\nimport { updateSchemaItemKey } from \"./Utils\";\nimport { type MutableClass } from \"../Editing/Mutable/MutableClass\";\nimport { CustomAttribute, ECClass, ECClassModifier, parseClassModifier, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { mergeClassProperties } from \"./PropertyMerger\";\nimport { applyCustomAttributes } from \"./CustomAttributeMerger\";\n\n/**\n * Shared modify merger of all ECClass based items.\n * @internal\n */\nexport async function modifyClass(context: SchemaMergeContext, change: AnyClassItemDifference, itemKey: SchemaItemKey, item: ECClass): Promise<void> {\n const mutableClass = item as MutableClass;\n if (change.difference.label !== undefined) {\n mutableClass.setDisplayLabel(change.difference.label);\n }\n\n if (change.difference.description !== undefined) {\n mutableClass.setDescription(change.difference.description);\n }\n\n if (change.difference.hasOwnProperty(\"baseClass\")) {\n // If the entry difference have a property baseClass and it is explicitly set to undefined,\n // it is expected to remove the base class, which is not allowed in this case.\n // TODO: We should consider using null for this case.\n if(change.difference.baseClass === undefined) {\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\n }\n await setBaseClass(context, item, change.difference.baseClass, change.changeType === \"add\");\n }\n\n if (change.difference.modifier !== undefined) {\n await setClassModifier(mutableClass, change.difference.modifier);\n }\n\n if (change.difference.customAttributes !== undefined) {\n await applyCustomAttributes(context, change.difference.customAttributes as CustomAttribute[], async (ca) => {\n await context.editor.entities.addCustomAttribute(itemKey, ca);\n });\n }\n\n return mergeClassProperties(context, change, itemKey);\n}\n\nasync function setBaseClass(context: SchemaMergeContext, item: ECClass, baseClass: string, isInitial: boolean): Promise<void> {\n if (!isInitial && (item.baseClass === undefined))\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\n\n const baseClassKey = await updateSchemaItemKey(context, baseClass);\n const baseClassSetter = getBaseClassSetter(context, item);\n\n await baseClassSetter(item.key, baseClassKey);\n}\n\nasync function setClassModifier(item: MutableClass, modifierValue: string): Promise<void> {\n const modifier = parseClassModifier(modifierValue);\n if (modifier === undefined) {\n throw new Error(\"An invalid class modifier has been provided.\");\n }\n if (item.modifier === undefined || item.modifier === modifier || modifier === ECClassModifier.None) {\n item.setModifier(modifier);\n return;\n }\n throw new Error(`Changing the class '${item.name}' modifier is not supported.`);\n}\n\nfunction getBaseClassSetter(context: SchemaMergeContext, item: ECClass) {\n return async (itemKey: SchemaItemKey, baseClassKey: SchemaItemKey) => {\n switch (item.schemaItemType) {\n case SchemaItemType.CustomAttributeClass: return context.editor.customAttributes.setBaseClass(itemKey, baseClassKey);\n case SchemaItemType.EntityClass: return context.editor.entities.setBaseClass(itemKey, baseClassKey);\n case SchemaItemType.Mixin: return context.editor.mixins.setBaseClass(itemKey, baseClassKey);\n case SchemaItemType.RelationshipClass: return context.editor.relationships.setBaseClass(itemKey, baseClassKey);\n case SchemaItemType.StructClass: return context.editor.structs.setBaseClass(itemKey, baseClassKey);\n }\n throw new Error(`Changing the base class '${item.name}' is not supported.`);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;AAgBA,kCA+BC;AAzCD,mCAA8C;AAE9C,gEAAwI;AACxI,qDAAwD;AACxD,mEAAgE;AAEhE;;;GAGG;AACI,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,MAA8B,EAAE,OAAsB,EAAE,IAAa;IAClI,MAAM,YAAY,GAAG,IAAoB,CAAC;IAC1C,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;QAClD,2FAA2F;QAC3F,8EAA8E;QAC9E,qDAAqD;QACrD,IAAG,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC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c,CAAC,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACrG,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,IAAI,qBAAqB,CAAC,CAAC;IAC9E,CAAC,CAAC;AACJ,CAAC","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\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { AnyClassItemDifference } from \"../Differencing/SchemaDifference\";\r\nimport { updateSchemaItemKey } from \"./Utils\";\r\nimport { type MutableClass } from \"../Editing/Mutable/MutableClass\";\r\nimport { CustomAttribute, ECClass, ECClassModifier, parseClassModifier, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { mergeClassProperties } from \"./PropertyMerger\";\r\nimport { applyCustomAttributes } from \"./CustomAttributeMerger\";\r\n\r\n/**\r\n * Shared modify merger of all ECClass based items.\r\n * @internal\r\n */\r\nexport async function modifyClass(context: SchemaMergeContext, change: AnyClassItemDifference, itemKey: SchemaItemKey, item: ECClass): Promise<void> {\r\n const mutableClass = item as MutableClass;\r\n if (change.difference.label !== undefined) {\r\n mutableClass.setDisplayLabel(change.difference.label);\r\n }\r\n\r\n if (change.difference.description !== undefined) {\r\n mutableClass.setDescription(change.difference.description);\r\n }\r\n\r\n if (change.difference.hasOwnProperty(\"baseClass\")) {\r\n // If the entry difference have a property baseClass and it is explicitly set to undefined,\r\n // it is expected to remove the base class, which is not allowed in this case.\r\n // TODO: We should consider using null for this case.\r\n if(change.difference.baseClass === undefined) {\r\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\r\n }\r\n await setBaseClass(context, item, change.difference.baseClass, change.changeType === \"add\");\r\n }\r\n\r\n if (change.difference.modifier !== undefined) {\r\n await setClassModifier(mutableClass, change.difference.modifier);\r\n }\r\n\r\n if (change.difference.customAttributes !== undefined) {\r\n await applyCustomAttributes(context, change.difference.customAttributes as CustomAttribute[], async (ca) => {\r\n await context.editor.entities.addCustomAttribute(itemKey, ca);\r\n });\r\n }\r\n\r\n return mergeClassProperties(context, change, itemKey);\r\n}\r\n\r\nasync function setBaseClass(context: SchemaMergeContext, item: ECClass, baseClass: string, isInitial: boolean): Promise<void> {\r\n if (!isInitial && (item.baseClass === undefined))\r\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\r\n\r\n const baseClassKey = await updateSchemaItemKey(context, baseClass);\r\n const baseClassSetter = getBaseClassSetter(context, item);\r\n\r\n await baseClassSetter(item.key, baseClassKey);\r\n}\r\n\r\nasync function setClassModifier(item: MutableClass, modifierValue: string): Promise<void> {\r\n const modifier = parseClassModifier(modifierValue);\r\n if (modifier === undefined) {\r\n throw new Error(\"An invalid class modifier has been provided.\");\r\n }\r\n if (item.modifier === undefined || item.modifier === modifier || modifier === ECClassModifier.None) {\r\n item.setModifier(modifier);\r\n return;\r\n }\r\n throw new Error(`Changing the class '${item.name}' modifier is not supported.`);\r\n}\r\n\r\nfunction getBaseClassSetter(context: SchemaMergeContext, item: ECClass) {\r\n return async (itemKey: SchemaItemKey, baseClassKey: SchemaItemKey) => {\r\n switch (item.schemaItemType) {\r\n case SchemaItemType.CustomAttributeClass: return context.editor.customAttributes.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.EntityClass: return context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.Mixin: return context.editor.mixins.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.RelationshipClass: return context.editor.relationships.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.StructClass: return context.editor.structs.setBaseClass(itemKey, baseClassKey);\r\n }\r\n throw new Error(`Changing the base class '${item.name}' is not supported.`);\r\n };\r\n}\r\n"]}
|
|
@@ -1 +1 @@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ChF,MAAM,IAAI,iCAAa,CAAC,kCAAc,CAAC,aAAa,EAAE,gBAAgB,MAAM,CAAC,QAAQ,wCAAwC,CAAC,CAAC;QACjI,CAAC;QACD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,8BAAU,CAAC,CAAC;QAC3F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAC5F,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC","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*--------------------------------------------------------------------------------------------*/\nimport type { ConstantDifference } from \"../Differencing/SchemaDifference\";\nimport type{ MutableConstant } from \"../Editing/Mutable/MutableConstant\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { DelayedPromiseWithProps, ECSchemaError, ECSchemaStatus, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Constant into the target schema.\n * @internal\n */\nexport async function addConstant(context: SchemaMergeContext, change: ConstantDifference) {\n if (change.difference.phenomenon === undefined) {\n throw new Error(\"Constant must define phenomenon\");\n }\n if (change.difference.definition === undefined) {\n throw new Error(\"Constant must define definition\");\n }\n\n // Needs to update the reference from source to target schema.\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\n\n await context.editor.constants.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n phenomenon: change.difference.phenomenon,\n definition: change.difference.definition,\n });\n}\n\n/**\n * Merges differences to an existing Constant in the target schema.\n * @internal\n */\nexport async function modifyConstant(context: SchemaMergeContext, change: ConstantDifference, itemKey: SchemaItemKey) {\n const constant = await context.targetSchema.lookupItem(itemKey) as MutableConstant;\n if (change.difference.label !== undefined) {\n await context.editor.constants.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.constants.setDescription(itemKey, change.difference.description);\n }\n\n // Note: There are no editor methods to modify a constant.\n if (change.difference.definition !== undefined) {\n if (change.difference.definition !== \"\" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'definition' attribute.`);\n }\n constant.setDefinition(change.difference.definition);\n }\n if (change.difference.denominator !== undefined) {\n if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'denominator' attribute.`);\n }\n constant.setDenominator(change.difference.denominator);\n }\n if (change.difference.numerator !== undefined) {\n if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'numerator' attribute.`);\n }\n constant.setNumerator(change.difference.numerator);\n }\n if (change.difference.phenomenon !== undefined) {\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\n const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey, Phenomenon);\n if (phenomenon === undefined) {\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\n }\n\n constant.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAcA,kCAkBC;AAMD,wCAqCC;AApED,gEAA6H;AAC7H,mCAAwE;AAExE;;;GAGG;AACI,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,MAA0B;IACvF,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,8DAA8D;IAC9D,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAErG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACtE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;QACxC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;KACzC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA0B,EAAE,OAAsB;IAClH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAoB,CAAC;IACnF,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KA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AAI,QAAQ,CAAC,YAAY,IAAI,QAAQ,CAAC,SAAS,KAAK,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;YAChF,MAAM,IAAI,iCAAa,CAAC,kCAAc,CAAC,aAAa,EAAE,gBAAgB,MAAM,CAAC,QAAQ,wCAAwC,CAAC,CAAC;QACjI,CAAC;QACD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,8BAAU,CAAC,CAAC;QAC3F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAC5F,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC","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\nimport type { ConstantDifference } from \"../Differencing/SchemaDifference\";\r\nimport type{ MutableConstant } from \"../Editing/Mutable/MutableConstant\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { DelayedPromiseWithProps, ECSchemaError, ECSchemaStatus, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new Constant into the target schema.\r\n * @internal\r\n */\r\nexport async function addConstant(context: SchemaMergeContext, change: ConstantDifference) {\r\n if (change.difference.phenomenon === undefined) {\r\n throw new Error(\"Constant must define phenomenon\");\r\n }\r\n if (change.difference.definition === undefined) {\r\n throw new Error(\"Constant must define definition\");\r\n }\r\n\r\n // Needs to update the reference from source to target schema.\r\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\r\n\r\n await context.editor.constants.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n phenomenon: change.difference.phenomenon,\r\n definition: change.difference.definition,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing Constant in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyConstant(context: SchemaMergeContext, change: ConstantDifference, itemKey: SchemaItemKey) {\r\n const constant = await context.targetSchema.lookupItem(itemKey) as MutableConstant;\r\n if (change.difference.label !== undefined) {\r\n await context.editor.constants.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if (change.difference.description !== undefined) {\r\n await context.editor.constants.setDescription(itemKey, change.difference.description);\r\n }\r\n\r\n // Note: There are no editor methods to modify a constant.\r\n if (change.difference.definition !== undefined) {\r\n if (change.difference.definition !== \"\" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'definition' attribute.`);\r\n }\r\n constant.setDefinition(change.difference.definition);\r\n }\r\n if (change.difference.denominator !== undefined) {\r\n if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'denominator' attribute.`);\r\n }\r\n constant.setDenominator(change.difference.denominator);\r\n }\r\n if (change.difference.numerator !== undefined) {\r\n if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'numerator' attribute.`);\r\n }\r\n constant.setNumerator(change.difference.numerator);\r\n }\r\n if (change.difference.phenomenon !== undefined) {\r\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\r\n const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey, Phenomenon);\r\n if (phenomenon === undefined) {\r\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\r\n }\r\n\r\n constant.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeClassMerger.ts"],"names":[],"mappings":";;AAcA,0DAWC;AAMD,gEAaC;AArCD,gEAAmH;AACnH,+CAA4C;AAE5C;;;GAGG;AACI,KAAK,UAAU,uBAAuB,CAAC,OAA2B,EAAE,MAAsC;IAC/G,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAC7E,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS;KACvC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,0BAA0B,CAAC,OAA2B,EAAE,MAAsC,EAAE,OAAsB;IAC1I,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAmB,CAAC;IAC9E,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,IAAA,yCAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,YAAY,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;YACxE,MAAM,aAAa,GAAG,IAAA,qDAAiC,EAAC,GAAG,YAAY,KAAK,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;YAC3G,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;YACxF,CAAC;YACD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC","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*--------------------------------------------------------------------------------------------*/\nimport type { CustomAttributeClassDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableCAClass } from \"../Editing/Mutable/MutableCAClass\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { containerTypeToString, parseCustomAttributeContainerType, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { modifyClass } from \"./ClassMerger\";\n\n/**\n * Merges a new CustomAttribute into the target schema.\n * @internal\n */\nexport async function addCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference) {\n if (change.difference.appliesTo === undefined) {\n throw new Error(\"appliesTo is a required property of a CustomAttributeClass but it is not set\");\n }\n\n await context.editor.customAttributes.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n appliesTo: change.difference.appliesTo,\n });\n}\n\n/**\n * Merges differences to an existing CustomAttribute in the target schema.\n * @internal\n */\nexport async function modifyCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableCAClass;\n if (change.difference.appliesTo !== undefined) {\n const currentValue = containerTypeToString(item.appliesTo);\n if (currentValue !== \"\" && change.difference.appliesTo !== currentValue) {\n const containerType = parseCustomAttributeContainerType(`${currentValue}, ${change.difference.appliesTo}`);\n if (containerType === undefined) {\n throw new Error(\"An invalid custom attribute class containerType has been provided.\");\n }\n item.setAppliesTo(containerType);\n }\n }\n return modifyClass(context, change, itemKey, item);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CustomAttributeClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeClassMerger.ts"],"names":[],"mappings":";;AAcA,0DAWC;AAMD,gEAaC;AArCD,gEAAmH;AACnH,+CAA4C;AAE5C;;;GAGG;AACI,KAAK,UAAU,uBAAuB,CAAC,OAA2B,EAAE,MAAsC;IAC/G,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAC7E,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS;KACvC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,0BAA0B,CAAC,OAA2B,EAAE,MAAsC,EAAE,OAAsB;IAC1I,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAmB,CAAC;IAC9E,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,IAAA,yCAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,YAAY,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;YACxE,MAAM,aAAa,GAAG,IAAA,qDAAiC,EAAC,GAAG,YAAY,KAAK,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;YAC3G,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;YACxF,CAAC;YACD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC","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\nimport type { CustomAttributeClassDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableCAClass } from \"../Editing/Mutable/MutableCAClass\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { containerTypeToString, parseCustomAttributeContainerType, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Merges a new CustomAttribute into the target schema.\r\n * @internal\r\n */\r\nexport async function addCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference) {\r\n if (change.difference.appliesTo === undefined) {\r\n throw new Error(\"appliesTo is a required property of a CustomAttributeClass but it is not set\");\r\n }\r\n\r\n await context.editor.customAttributes.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n appliesTo: change.difference.appliesTo,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing CustomAttribute in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference, itemKey: SchemaItemKey) {\r\n const item = await context.targetSchema.lookupItem(itemKey) as MutableCAClass;\r\n if (change.difference.appliesTo !== undefined) {\r\n const currentValue = containerTypeToString(item.appliesTo);\r\n if (currentValue !== \"\" && change.difference.appliesTo !== currentValue) {\r\n const containerType = parseCustomAttributeContainerType(`${currentValue}, ${change.difference.appliesTo}`);\r\n if (containerType === undefined) {\r\n throw new Error(\"An invalid custom attribute class containerType has been provided.\");\r\n }\r\n item.setAppliesTo(containerType);\r\n }\r\n }\r\n return modifyClass(context, change, itemKey, item);\r\n}\r\n"]}
|