@itwin/ecschema-editing 4.6.0-dev.3 → 4.6.0-dev.5
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/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/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/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/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/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/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/CAClassMerger.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/CustomAttributeMerger.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/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.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/SchemaItemFactory.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.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/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/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":["/*---------------------------------------------------------------------------------------------\
|
|
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 +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;CAEzD;AAFD,8CAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
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;CAEzD;AAFD,8CAEC","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}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Phenomena.js","sourceRoot":"","sources":["../../../src/Editing/Phenomena.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,MAAa,SAAS;IACpB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,YAAqB;QAC/F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAA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,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;CACF;AAnCD,8BAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"Phenomena.js","sourceRoot":"","sources":["../../../src/Editing/Phenomena.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,MAAa,SAAS;IACpB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,YAAqB;QAC/F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAsB,CAAC;QACjF,IAAI,aAAa,KAAK,SAAS;YAC7B,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnG,IAAI,YAAY;YACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAE9C,MAAM,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAE9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,eAAe,CAAC,IAAI,KAAK,SAAS;YACpC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,IAAI,aAAa,KAAK,SAAS;YAC7B,OAAO,EAAE,YAAY,EAAE,0BAA0B,eAAe,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnH,MAAM,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;CACF;AAnCD,8BAmCC","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 { PhenomenonProps, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutablePhenomenon } from \"./Mutable/MutablePhenomenon\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Phenomenon.\n */\nexport class Phenomena {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, displayLabel?: string): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newPhenomenon = (await schema.createPhenomenon(name)) as MutablePhenomenon;\n if (newPhenomenon === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n if (displayLabel)\n newPhenomenon.setDisplayLabel(displayLabel);\n\n await newPhenomenon.setDefinition(definition);\n\n return { itemKey: newPhenomenon.key };\n }\n\n public async createFromProps(schemaKey: SchemaKey, phenomenonProps: PhenomenonProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (phenomenonProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newPhenomenon = (await schema.createPhenomenon(phenomenonProps.name));\n if (newPhenomenon === undefined)\n return { errorMessage: `Failed to create class ${phenomenonProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newPhenomenon.fromJSON(phenomenonProps);\n return { itemKey: newPhenomenon.key };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyCategories.js","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA4I;AAI5I;;;GAGG;AACH,MAAa,kBAAkB;IAC7B,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAgB,EAAE,YAAqB;QAC7F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,eAAe,GAAG,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAA4B,CAAC;QAC/F,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,YAAY;YACd,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAEhD,OAAO,EA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eAAe,CAAC,QAAQ,mCAAmC,CAAC,CAAC;QAE3I,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;CACF;AA1CD,gDA0CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"PropertyCategories.js","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA4I;AAI5I;;;GAGG;AACH,MAAa,kBAAkB;IAC7B,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAgB,EAAE,YAAqB;QAC7F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,eAAe,GAAG,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAA4B,CAAC;QAC/F,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,YAAY;YACd,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAEhD,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC;IAC1C,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,qBAA4C;QAC7F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,qBAAqB,CAAC,IAAI,KAAK,SAAS;YAC1C,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,eAAe,GAAG,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAA4B,CAAC;QACrH,IAAI,eAAe,KAAK,SAAS;YAC/B,OAAO,EAAE,YAAY,EAAE,0BAA0B,qBAAqB,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEzH,MAAM,eAAe,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC;IAC1C,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,eAA8B,EAAE,QAAgB;QACvE,MAAM,gBAAgB,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAA0B,eAAe,CAAC,CAAC,CAAC;QAE1H,IAAI,gBAAgB,KAAK,SAAS;YAChC,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,qBAAqB,eAAe,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAExI,IAAI,gBAAgB,CAAC,cAAc,KAAK,kCAAc,CAAC,gBAAgB;YACrE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,eAAe,CAAC,QAAQ,mCAAmC,CAAC,CAAC;QAE3I,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;CACF;AA1CD,gDA0CC","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 { ECObjectsError, ECObjectsStatus, PropertyCategoryProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutablePropertyCategory } from \"./Mutable/MutablePropertyCategory\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Property Category.\n */\nexport class PropertyCategories {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newPropCategory = (await schema.createPropertyCategory(name)) as MutablePropertyCategory;\n newPropCategory.setPriority(priority);\n if (displayLabel)\n newPropCategory.setDisplayLabel(displayLabel);\n\n return { itemKey: newPropCategory.key };\n }\n\n public async createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (propertyCategoryProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newPropCategory = (await schema.createPropertyCategory(propertyCategoryProps.name)) as MutablePropertyCategory;\n if (newPropCategory === undefined)\n return { errorMessage: `Failed to create class ${propertyCategoryProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newPropCategory.fromJSON(propertyCategoryProps);\n return { itemKey: newPropCategory.key };\n }\n\n public async setPriority(propCategoryKey: SchemaItemKey, priority: number): Promise<void> {\n const propertyCategory = (await this._schemaEditor.schemaContext.getSchemaItem<MutablePropertyCategory>(propCategoryKey));\n\n if (propertyCategory === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Property Category ${propCategoryKey.fullName} not found in schema context.`);\n\n if (propertyCategory.schemaItemType !== SchemaItemType.PropertyCategory)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${propCategoryKey.fullName} to be of type Property Category.`);\n\n propertyCategory.setPriority(priority);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClasses.js","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAIkC;AAElC,2CAAwC;AAExC,+CAA+C;AAG/C;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,qBAAS;IAChD,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAyB,EAAE,QAAsB,EAAE,SAA4B,EAAE,YAA4B;QACnK,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;SACxF;QAED,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,uBAAuB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAA6B,CAAC;QACpG,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,MAAM,eAAe,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAChJ,IAAI,eAAe,KAAK,SAAS,EAAE;gBACjC,OAAO,EAAE,YAAY,EAAE,cAAc,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;aACrG;YAED,MAAM,aAAa,G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I,KAAK,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;SACrE;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,OAAO,EAAE,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;SACrD;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAjPD,kDAiPC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport {\r\n CustomAttribute, DelayedPromiseWithProps, 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 { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableRelationshipClass, MutableRelationshipConstraint } from \"./Mutable/MutableRelationshipClass\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { RelationshipConstraintDiagnostic, SchemaItemDiagnostic } from \"../Validation/Diagnostic\";\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 public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\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<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined) {\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n }\r\n\r\n const newClass = (await schema.createRelationshipClass(name, modifier)) as MutableRelationshipClass;\r\n if (baseClassKey !== undefined) {\r\n const baseClassSchema = !baseClassKey.schemaKey.matches(schema.schemaKey) ? await this._schemaEditor.getSchema(baseClassKey.schemaKey) : schema;\r\n if (baseClassSchema === undefined) {\r\n return { errorMessage: `Schema Key ${baseClassKey.schemaKey.toString(true)} not found in context` };\r\n }\r\n\r\n const baseClassItem = await baseClassSchema.lookupItem<RelationshipClass>(baseClassKey);\r\n if (baseClassItem === undefined)\r\n return { errorMessage: `Unable to locate base class ${baseClassKey.fullName} in schema ${baseClassSchema.fullName}.` };\r\n\r\n if (baseClassItem.schemaItemType !== SchemaItemType.RelationshipClass)\r\n return { errorMessage: `${baseClassItem.fullName} is not of type Relationship Class.` };\r\n\r\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, RelationshipClass>(baseClassKey, async () => baseClassItem);\r\n }\r\n\r\n newClass.setStrength(strength);\r\n newClass.setStrengthDirection(direction);\r\n\r\n return { itemKey: newClass.key };\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 * @returns A promise of type SchemaItemEditResults.\r\n */\r\n public async setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<SchemaItemEditResults> {\r\n const relationship = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\r\n\r\n if (relationship === undefined)\r\n return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\r\n\r\n relationship.setSourceConstraint(source);\r\n return { itemKey: relationshipKey };\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 * @returns A promise of type SchemaItemEditResults.\r\n */\r\n public async setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<SchemaItemEditResults> {\r\n const relationship = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\r\n\r\n if (relationship === undefined)\r\n return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\r\n\r\n relationship.setTargetConstraint(target);\r\n return { itemKey: relationshipKey };\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<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (relationshipProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newClass = (await schema.createRelationshipClass(relationshipProps.name)) as MutableRelationshipClass;\r\n await newClass.fromJSON(relationshipProps);\r\n await newClass.source.fromJSON(relationshipProps.source);\r\n await newClass.target.fromJSON(relationshipProps.target);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n public async createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults> {\r\n const relationshipClass = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\r\n\r\n if (relationshipClass === undefined)\r\n return { itemKey: relationshipKey, propertyName: name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\r\n\r\n if (relationshipClass.schemaItemType !== SchemaItemType.RelationshipClass)\r\n return { itemKey: relationshipKey, propertyName: name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };\r\n\r\n await relationshipClass.createNavigationProperty(name, relationship, direction);\r\n return { itemKey: relationshipKey, propertyName: name };\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<PropertyEditResults> {\r\n const relationshipClass = await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey);\r\n\r\n if (relationshipClass === undefined)\r\n return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\r\n\r\n if (relationshipClass.schemaItemType !== SchemaItemType.RelationshipClass)\r\n return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };\r\n\r\n const property = await relationshipClass.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\r\n await property.fromJSON(navigationProps);\r\n return { itemKey: relationshipKey, propertyName: navigationProps.name };\r\n }\r\n\r\n public async setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<SchemaItemEditResults> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.multiplicity = multiplicity;\r\n return { itemKey: constraint.relationshipClass.key };\r\n }\r\n\r\n public async setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<SchemaItemEditResults> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.polymorphic = polymorphic;\r\n return { itemKey: constraint.relationshipClass.key };\r\n }\r\n\r\n public async setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<SchemaItemEditResults> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.relationshipEnd = relationshipEnd;\r\n return { itemKey: constraint.relationshipClass.key };\r\n }\r\n\r\n public async setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults> {\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.abstractConstraint = undefined;\r\n } else {\r\n mutableConstraint.abstractConstraint = new DelayedPromiseWithProps(abstractConstraint.key, async () => abstractConstraint);\r\n }\r\n\r\n let result = await this.validate(constraint.relationshipClass);\r\n if (result.errorMessage) {\r\n mutableConstraint.abstractConstraint = existing;\r\n return result;\r\n }\r\n\r\n result = await this.validate(constraint);\r\n if (result.errorMessage) {\r\n mutableConstraint.abstractConstraint = existing;\r\n return result;\r\n }\r\n\r\n return { itemKey: constraint.relationshipClass.key };\r\n }\r\n\r\n public async addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.addClass(ecClass);\r\n\r\n let result = await this.validate(constraint.relationshipClass);\r\n if (result.errorMessage) {\r\n mutableConstraint.removeClass(ecClass);\r\n return result;\r\n }\r\n\r\n result = await this.validate(constraint);\r\n if (result.errorMessage) {\r\n mutableConstraint.removeClass(ecClass);\r\n return result;\r\n }\r\n\r\n return { itemKey: constraint.relationshipClass.key };\r\n }\r\n\r\n public async removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.removeClass(ecClass);\r\n\r\n const result = await this.validate(constraint);\r\n if (result.errorMessage) {\r\n mutableConstraint.addClass(ecClass);\r\n return result;\r\n }\r\n\r\n return { itemKey: constraint.relationshipClass.key };\r\n }\r\n\r\n public async addCustomAttributeToConstraint(constraint: RelationshipConstraint, customAttribute: CustomAttribute): Promise<SchemaItemEditResults> {\r\n const mutableConstraint = constraint as MutableRelationshipConstraint;\r\n mutableConstraint.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(constraint, customAttribute);\r\n const result: SchemaItemEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeCustomAttribute(constraint, customAttribute);\r\n return result;\r\n }\r\n\r\n return { itemKey: constraint.relationshipClass.key };\r\n }\r\n\r\n private async validate(relationshipOrConstraint: RelationshipClass | RelationshipConstraint): Promise<SchemaItemEditResults> {\r\n let diagnostics: AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> | AsyncIterable<RelationshipConstraintDiagnostic<any[]>>;\r\n\r\n if (relationshipOrConstraint instanceof RelationshipClass) {\r\n diagnostics = Rules.validateRelationship(relationshipOrConstraint);\r\n } else {\r\n diagnostics = Rules.validateRelationshipConstraint(relationshipOrConstraint);\r\n }\r\n\r\n const errorMessages = [];\r\n for await (const diagnostic of diagnostics) {\r\n errorMessages.push(`${diagnostic.code}: ${diagnostic.messageText}`);\r\n }\r\n\r\n if (errorMessages.length > 0) {\r\n return { errorMessage: errorMessages.join(\"\\r\\n\") };\r\n }\r\n\r\n return {};\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RelationshipClasses.js","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAIkC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DAiPC","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, ECClassModifier, EntityClass, LazyLoadedRelationshipConstraintClass, Mixin, NavigationPropertyProps,\n RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaItemType,\n SchemaKey, StrengthDirection, StrengthType,\n} from \"@itwin/ecschema-metadata\";\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableRelationshipClass, MutableRelationshipConstraint } from \"./Mutable/MutableRelationshipClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { RelationshipConstraintDiagnostic, SchemaItemDiagnostic } from \"../Validation/Diagnostic\";\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 public constructor(_schemaEditor: SchemaContextEditor) {\n super(_schemaEditor);\n }\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<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined) {\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n }\n\n const newClass = (await schema.createRelationshipClass(name, modifier)) as MutableRelationshipClass;\n if (baseClassKey !== undefined) {\n const baseClassSchema = !baseClassKey.schemaKey.matches(schema.schemaKey) ? await this._schemaEditor.getSchema(baseClassKey.schemaKey) : schema;\n if (baseClassSchema === undefined) {\n return { errorMessage: `Schema Key ${baseClassKey.schemaKey.toString(true)} not found in context` };\n }\n\n const baseClassItem = await baseClassSchema.lookupItem<RelationshipClass>(baseClassKey);\n if (baseClassItem === undefined)\n return { errorMessage: `Unable to locate base class ${baseClassKey.fullName} in schema ${baseClassSchema.fullName}.` };\n\n if (baseClassItem.schemaItemType !== SchemaItemType.RelationshipClass)\n return { errorMessage: `${baseClassItem.fullName} is not of type Relationship Class.` };\n\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, RelationshipClass>(baseClassKey, async () => baseClassItem);\n }\n\n newClass.setStrength(strength);\n newClass.setStrengthDirection(direction);\n\n return { itemKey: newClass.key };\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 * @returns A promise of type SchemaItemEditResults.\n */\n public async setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<SchemaItemEditResults> {\n const relationship = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\n\n if (relationship === undefined)\n return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\n\n relationship.setSourceConstraint(source);\n return { itemKey: relationshipKey };\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 * @returns A promise of type SchemaItemEditResults.\n */\n public async setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<SchemaItemEditResults> {\n const relationship = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\n\n if (relationship === undefined)\n return { itemKey: relationshipKey, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\n\n relationship.setTargetConstraint(target);\n return { itemKey: relationshipKey };\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<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (relationshipProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newClass = (await schema.createRelationshipClass(relationshipProps.name)) as MutableRelationshipClass;\n await newClass.fromJSON(relationshipProps);\n await newClass.source.fromJSON(relationshipProps.source);\n await newClass.target.fromJSON(relationshipProps.target);\n\n return { itemKey: newClass.key };\n }\n\n public async createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults> {\n const relationshipClass = (await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey));\n\n if (relationshipClass === undefined)\n return { itemKey: relationshipKey, propertyName: name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\n\n if (relationshipClass.schemaItemType !== SchemaItemType.RelationshipClass)\n return { itemKey: relationshipKey, propertyName: name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };\n\n await relationshipClass.createNavigationProperty(name, relationship, direction);\n return { itemKey: relationshipKey, propertyName: name };\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<PropertyEditResults> {\n const relationshipClass = await this._schemaEditor.schemaContext.getSchemaItem<MutableRelationshipClass>(relationshipKey);\n\n if (relationshipClass === undefined)\n return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Relationship Class ${relationshipKey.fullName} not found in schema context.` };\n\n if (relationshipClass.schemaItemType !== SchemaItemType.RelationshipClass)\n return { itemKey: relationshipKey, propertyName: navigationProps.name, errorMessage: `Expected ${relationshipKey.fullName} to be of type Relationship Class.` };\n\n const property = await relationshipClass.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\n await property.fromJSON(navigationProps);\n return { itemKey: relationshipKey, propertyName: navigationProps.name };\n }\n\n public async setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.multiplicity = multiplicity;\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.polymorphic = polymorphic;\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.relationshipEnd = relationshipEnd;\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults> {\n const existing: LazyLoadedRelationshipConstraintClass | undefined = constraint.abstractConstraint;\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n\n if (undefined === abstractConstraint) {\n mutableConstraint.abstractConstraint = undefined;\n } else {\n mutableConstraint.abstractConstraint = new DelayedPromiseWithProps(abstractConstraint.key, async () => abstractConstraint);\n }\n\n let result = await this.validate(constraint.relationshipClass);\n if (result.errorMessage) {\n mutableConstraint.abstractConstraint = existing;\n return result;\n }\n\n result = await this.validate(constraint);\n if (result.errorMessage) {\n mutableConstraint.abstractConstraint = existing;\n return result;\n }\n\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.addClass(ecClass);\n\n let result = await this.validate(constraint.relationshipClass);\n if (result.errorMessage) {\n mutableConstraint.removeClass(ecClass);\n return result;\n }\n\n result = await this.validate(constraint);\n if (result.errorMessage) {\n mutableConstraint.removeClass(ecClass);\n return result;\n }\n\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.removeClass(ecClass);\n\n const result = await this.validate(constraint);\n if (result.errorMessage) {\n mutableConstraint.addClass(ecClass);\n return result;\n }\n\n return { itemKey: constraint.relationshipClass.key };\n }\n\n public async addCustomAttributeToConstraint(constraint: RelationshipConstraint, customAttribute: CustomAttribute): Promise<SchemaItemEditResults> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(constraint, customAttribute);\n const result: SchemaItemEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(constraint, customAttribute);\n return result;\n }\n\n return { itemKey: constraint.relationshipClass.key };\n }\n\n private async validate(relationshipOrConstraint: RelationshipClass | RelationshipConstraint): Promise<SchemaItemEditResults> {\n let diagnostics: AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> | AsyncIterable<RelationshipConstraintDiagnostic<any[]>>;\n\n if (relationshipOrConstraint instanceof RelationshipClass) {\n diagnostics = Rules.validateRelationship(relationshipOrConstraint);\n } else {\n diagnostics = Rules.validateRelationshipConstraint(relationshipOrConstraint);\n }\n\n const errorMessages = [];\n for await (const diagnostic of diagnostics) {\n errorMessages.push(`${diagnostic.code}: ${diagnostic.messageText}`);\n }\n\n if (errorMessages.length > 0) {\n return { errorMessage: errorMessages.join(\"\\r\\n\") };\n }\n\n return {};\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA2G;AAG3G;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,UAAU,CAAC,aAA4B,EAAE,cAA+B;QACnF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAEvF,IAAI,UAAU,KAAK,SAAS;YAC1B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,eAAe,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEhI,MAAM,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC5C,CAAC;CACF;AAVD,kCAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA2G;AAG3G;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,UAAU,CAAC,aAA4B,EAAE,cAA+B;QACnF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAEvF,IAAI,UAAU,KAAK,SAAS;YAC1B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,eAAe,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAEhI,MAAM,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC5C,CAAC;CACF;AAVD,kCAUC","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 { ECObjectsError, ECObjectsStatus, SchemaItemKey, SchemaItemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\n\n/**\n * @internal\n * A class allowing you to edit the schema item base class.\n */\nexport class SchemaItems {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async applyProps(schemaItemKey: SchemaItemKey, schemItemProps: SchemaItemProps): Promise<void> {\n const schemaItem = await this._schemaEditor.schemaContext.getSchemaItem(schemaItemKey);\n\n if (schemaItem === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Schema Item ${schemaItemKey.fullName} not found in schema context.`);\n\n await schemaItem.fromJSON(schemItemProps);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAqJ;AAErJ,2CAAwC;AAGxC;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,SAAyB;QACtG,MAAM,MAAM,GAAG,MA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AAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS;YAChC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAiB,CAAC;QACpF,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,WAAW,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/G,MAAM,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AAnDD,0BAmDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAqJ;AAErJ,2CAAwC;AAGxC;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,SAAyB;QACtG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,IAA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CAAC,IAAI,CAAC,CAAiB,CAAC;QACpF,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,WAAW,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/G,MAAM,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AAnDD,0BAmDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, ECClass, SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableClass, MutableStructClass } from \"./Mutable/MutableClass\";\n\n/**\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\n */\nexport class Structs extends ECClasses {\n public constructor(_schemaEditor: SchemaContextEditor) {\n super(_schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newClass = (await schema.createStructClass(name)) as MutableStructClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n if (baseClass !== undefined) {\n const baseClassItem = await schema.lookupItem<StructClass>(baseClass);\n if (baseClassItem === undefined)\n return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };\n\n if (baseClassItem.schemaItemType !== SchemaItemType.StructClass)\n return { errorMessage: `${baseClassItem.fullName} is not of type Struct Class.` };\n\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClass, async () => baseClassItem);\n }\n\n if (displayLabel)\n newClass.setDisplayLabel(displayLabel);\n\n return { itemKey: newClass.key };\n }\n\n /**\n * Creates a StructClass through a StructClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (structProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newClass = (await schema.createStructClass(structProps.name)) as MutableClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${structProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newClass.fromJSON(structProps);\n return { itemKey: newClass.key };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAC3E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAsB,CAAC;QACjF,IAAI,YAAY;YACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAE9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,eAAe,CAAC,IAAI,KAAK,SAAS;YACpC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAsB,CAAC;QACjG,IAAI,aAAa,KAAK,SAAS;YAC7B,OAAO,EAAE,YAAY,EAAE,0BAA0B,eAAe,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnH,MAAM,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC9C,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;CACF;AA7BD,kCA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAMH;;;GAGG;AACH,MAAa,WAAW;IACtB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IA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------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { SchemaKey, UnitSystemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type UnitSystems.\n */\nexport class UnitSystems {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newUnitSystem = (await schema.createUnitSystem(name)) as MutableUnitSystem;\n if (displayLabel)\n newUnitSystem.setDisplayLabel(displayLabel);\n\n return { itemKey: newUnitSystem.key };\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (unitSystemProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newUnitSystem = (await schema.createUnitSystem(unitSystemProps.name)) as MutableUnitSystem;\n if (newUnitSystem === undefined)\n return { errorMessage: `Failed to create class ${unitSystemProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newUnitSystem.fromJSON(unitSystemProps);\n return { itemKey: newUnitSystem.key };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA0J;AAI1J;;;GAGG;AACH,MAAa,KAAK;IAChB,6CA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BAsDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA0J;AAI1J;;;GAGG;AACH,MAAa,KAAK;IAChB,6CAA6C;IAC7C,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAyB,EAAE,UAAyB,EAAE,YAAqB;QACrJ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAgB,CAAC;QAC/D,IAAI,OAAO,KAAK,SAAS;YACvB,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnG,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,UAAU,CAAa,UAAU,CAAC,CAAC;QACvE,IAAI,cAAc,KAAK,SAAS;YAC9B,OAAO,EAAE,YAAY,EAAE,+BAA+B,UAAU,CAAC,QAAQ,cAAc,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC;QAE9G,IAAI,cAAc,CAAC,cAAc,KAAK,kCAAc,CAAC,UAAU;YAC7D,OAAO,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,QAAQ,6BAA6B,EAAE,CAAC;QAE/E,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KA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IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7G,MAAM,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAClC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;CACF;AAtDD,sBAsDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Unit.\n */\nexport class Units {\n // TODO: Add more setters for all attributes.\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newUnit = (await schema.createUnit(name)) as MutableUnit;\n if (newUnit === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n const phenomenonItem = await schema.lookupItem<Phenomenon>(phenomenon);\n if (phenomenonItem === undefined)\n return { errorMessage: `Unable to locate phenomenon ${phenomenon.fullName} in schema ${schema.fullName}.` };\n\n if (phenomenonItem.schemaItemType !== SchemaItemType.Phenomenon)\n return { errorMessage: `${phenomenon.fullName} is not of type Phenomenon.` };\n\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\n\n const unitSystemItem = await schema.lookupItem<UnitSystem>(unitSystem);\n if (unitSystemItem === undefined)\n return { errorMessage: `Unable to locate unit system ${unitSystem.fullName} in schema ${schema.fullName}.` };\n\n if (unitSystemItem.schemaItemType !== SchemaItemType.UnitSystem)\n return { errorMessage: `${unitSystem.fullName} is not of type UnitSystem.` };\n\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\n\n await newUnit.setDefinition(definition);\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return { itemKey: newUnit.key };\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (unitProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newUnit = (await schema.createUnit(unitProps.name));\n if (newUnit === undefined)\n return { errorMessage: `Failed to create class ${unitProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newUnit.fromJSON(unitProps);\n return { itemKey: newUnit.key };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CAClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA8G;AAC9G,+CAA4C;AAI5C;;GAEG;AACH,MAAqB,aAAc,SAAQ,yBAAiC;IAEvD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAA6B;QACjF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACrG,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAA6B,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC3I,MAAM,cAAc,GAAG,OAAoC,CAAC;QAC5D,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,EAAE;oBAC9E,MAAM,aAAa,GAAG,IAAA,qDAAiC,EAAC,GAAG,iBAAiB,KAAK,iBAAiB,EAAE,CAAC,CAAC;oBACtG,IAAI,aAAa,KAAK,SAAS,EAAE;wBAC/B,OAAO,EAAE,YAAY,EAAE,oEAAoE,EAAC,CAAC;qBAC9F;oBACD,cAAc,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;iBAChD;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAC7F,CAAC;CACF;AArBD,gCAqBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"CAClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA8G;AAC9G,+CAA4C;AAI5C;;GAEG;AACH,MAAqB,aAAc,SAAQ,yBAAiC;IAEvD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAA6B;QACjF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACrG,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAA6B,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC3I,MAAM,cAAc,GAAG,OAAoC,CAAC;QAC5D,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,EAAE;oBAC9E,MAAM,aAAa,GAAG,IAAA,qDAAiC,EAAC,GAAG,iBAAiB,KAAK,iBAAiB,EAAE,CAAC,CAAC;oBACtG,IAAI,aAAa,KAAK,SAAS,EAAE;wBAC/B,OAAO,EAAE,YAAY,EAAE,oEAAoE,EAAC,CAAC;qBAC9F;oBACD,cAAc,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;iBAChD;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAC7F,CAAC;CACF;AArBD,gCAqBC","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 { CustomAttributeClass, parseCustomAttributeContainerType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { MutableCAClass } from \"../Editing/Mutable/MutableCAClass\";\n\n/**\n * @internal\n */\nexport default class CAClassMerger extends ClassMerger<CustomAttributeClass> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: CustomAttributeClass): Promise<SchemaItemEditResults> {\n return this.context.editor.customAttributes.create(schemaKey, ecClass.name, ecClass.containerType);\n }\n\n protected override async mergeAttributes(ecClass: CustomAttributeClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const mutableCAClass = ecClass as unknown as MutableCAClass;\n switch(attributeName) {\n case \"appliesTo\":\n if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {\n const containerType = parseCustomAttributeContainerType(`${attributeOldValue}, ${attributeNewValue}`);\n if (containerType === undefined) {\n return { errorMessage: \"An invalid custom attribute class containerType has been provided.\"};\n }\n mutableCAClass.setContainerType(containerType);\n }\n return true;\n }\n return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAoK;AAIpK,+DAA6H;AAC7H,mEAAgE;AAChE,qDAA+F;AAE/F;;GAEG;AACH,MAAa,WAAW;IAGtB,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,MAAM,CAAC,UAAqB,EAAE,OAAe;QAC3D,OAAO,EAAE,YAAY,EAAE,GAAG,IAAA,0CAAsB,EAAC,OAAO,CAAC,cAAc,CAAC,iCAAiC,EAAC,CAAC;IAC7G,CAAC;IAES,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,OAAqB;QACjE,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACpH,MAAM,YAAY,GAAG,OAAkC,CAAC;QACxD,QAAO,aAAa,EAAE;YACpB,KAAK,gBAAgB;gBACnB,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,EAAE;oBAC9E,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,0BAA0B,EAAE,CAAC;iBACxF;gBACD,OAAO,IAAI,CAAC;YAEd,KAAK,OAAO;gBACV,YAAY,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;gBAChD,OAAO,IAAI,CAAC;YAEd,KAAK,aAAa;gBAChB,YAAY,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;gBAC/C,OAAO,IAAI,CAAC;YAEd,KAAK,UAAU;gBACb,MAAM,QAAQ,GAAG,IAAA,sCAAkB,EAAC,iBAAiB,CAAC,CAAC;gBACvD,IAAI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C,aAAa,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;aACjG;YAED,yBAAyB;YACzB,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,0BAA0B,CAAC,aAAa,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAExG,qCAAqC;YACrC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;YAE9D,wCAAwC;YACxC,IAAI,MAAM,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE;gBACnC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,oBAAoB,CAAC,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;aACvG;YAED,0BAA0B;YAC1B,MAAM,MAAM,CAAC,WAAW,CAAC,IAAA,6CAAqB,EAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;gBAClH,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YAC9E,CAAC,CAAC,CAAC,CAAC;SACL;IACH,CAAC;CACF;AAlMD,kCAkMC","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 { ECClass, ECClassModifier, parseClassModifier, Property, SchemaItemKey, SchemaItemType, schemaItemTypeToString, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { MutableClass } from \"../Editing/Mutable/MutableClass\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { BaseClassDelta, ChangeType, ClassChanges, PropertyChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\r\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\r\nimport { createPropertyFromProps, mergePropertyAttributeValueChanges } from \"./PropertyMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class ClassMerger<TClass extends ECClass> {\r\n protected readonly context: SchemaMergeContext;\r\n\r\n constructor(context: SchemaMergeContext) {\r\n this.context = context;\r\n }\r\n\r\n protected async create(_schemaKey: SchemaKey, ecClass: TClass): Promise<SchemaItemEditResults> {\r\n return { errorMessage: `${schemaItemTypeToString(ecClass.schemaItemType)} class type is not implemented.`};\r\n }\r\n\r\n protected async merge(itemKey: SchemaItemKey, _change: ClassChanges): Promise<SchemaItemEditResults> {\r\n return { itemKey };\r\n }\r\n\r\n protected async mergeAttributes(ecClass: TClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\r\n const mutableClass = ecClass as unknown as MutableClass;\r\n switch(attributeName) {\r\n case \"schemaItemType\":\r\n if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {\r\n return { errorMessage: `Changing the class '${ecClass.name}' type is not supported.` };\r\n }\r\n return true;\r\n\r\n case \"label\":\r\n mutableClass.setDisplayLabel(attributeNewValue);\r\n return true;\r\n\r\n case \"description\":\r\n mutableClass.setDescription(attributeNewValue);\r\n return true;\r\n\r\n case \"modifier\":\r\n const modifier = parseClassModifier(attributeNewValue);\r\n if (modifier === undefined) {\r\n return { errorMessage: \"An invalid class modifier has been provided.\" };\r\n }\r\n\r\n if (attributeOldValue === undefined || modifier === ECClassModifier.None) {\r\n mutableClass.setModifier(modifier);\r\n return true;\r\n }\r\n return { errorMessage: `Changing the class '${ecClass.name}' modifier is not supported.` };\r\n }\r\n return false;\r\n }\r\n\r\n protected isSchemaItemEditResults(obj: any): obj is SchemaItemEditResults {\r\n return typeof obj === \"object\" && \"errorMessage\" in obj;\r\n }\r\n\r\n private async setBaseClass(itemKey: SchemaItemKey, baseClassDelta: BaseClassDelta, changeType?: ChangeType): Promise<SchemaItemEditResults> {\r\n const [sourceBaseClass, targetBaseClass] = baseClassDelta.diagnostic.messageArgs! as [ECClass, ECClass];\r\n if (sourceBaseClass !== undefined) {\r\n const baseClassKey = new SchemaItemKey(sourceBaseClass.name, sourceBaseClass.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : sourceBaseClass.schema.schemaKey);\r\n\r\n if (changeType === ChangeType.Missing && targetBaseClass === undefined) {\r\n if (sourceBaseClass.schemaItemType === SchemaItemType.EntityClass) {\r\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n } else if (sourceBaseClass.schemaItemType === SchemaItemType.Mixin) {\r\n return this.context.editor.mixins.setMixinBaseClass(itemKey, baseClassKey);\r\n }\r\n }\r\n\r\n if (targetBaseClass !== undefined) {\r\n const baseClass = await this.context.targetSchema.lookupItem<ECClass>(baseClassKey);\r\n if (baseClass === undefined) {\r\n return { errorMessage: `'${baseClassKey.name}' class could not be located in the merged schema.`};\r\n }\r\n if (await baseClass.is(targetBaseClass)) {\r\n if (baseClass.schemaItemType === SchemaItemType.EntityClass) {\r\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n } else if (baseClass.schemaItemType === SchemaItemType.Mixin) {\r\n return this.context.editor.mixins.setMixinBaseClass(itemKey, baseClassKey);\r\n }\r\n }\r\n }\r\n }\r\n return { errorMessage: `Changing the class '${itemKey.name}' baseClass is not supported.`};\r\n }\r\n\r\n private async mergeAttributeValueChanges(itemKey: SchemaItemKey, propertyValueChanges: PropertyValueChange[]): Promise<SchemaItemEditResults> {\r\n if (propertyValueChanges.length > 0) {\r\n\r\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\r\n if (targetItem === undefined) {\r\n return { errorMessage: `'${itemKey.name}' class could not be located in the merged schema.` };\r\n }\r\n\r\n for (const change of propertyValueChanges) {\r\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\r\n const results = await this.mergeAttributes(targetItem, attributeName, attributeNewValue, attributeOldValue);\r\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n }\r\n }\r\n\r\n return { itemKey };\r\n }\r\n\r\n private async handleError(callback: Promise<SchemaItemEditResults>) {\r\n const result = await callback;\r\n if (result.errorMessage) {\r\n throw new Error(result.errorMessage);\r\n }\r\n }\r\n\r\n private async mergePropertyChanges(itemKey: SchemaItemKey, propertyChanges: Iterable<PropertyChanges>): Promise<SchemaItemEditResults> {\r\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\r\n if (targetItem === undefined) {\r\n return { itemKey, errorMessage: `'${itemKey.name}' class could not be located in the merged schema.`};\r\n }\r\n\r\n for (const change of propertyChanges) {\r\n if (change.propertyMissing?.changeType === ChangeType.Missing) {\r\n if (await targetItem.getProperty(change.ecTypeName) !== undefined) {\r\n return { itemKey, errorMessage: `Merged schema already contains a class '${itemKey.name}' property '${change.ecTypeName}'.`};\r\n }\r\n\r\n const sourceProperty = change.propertyMissing.diagnostic.ecDefinition as unknown as Property;\r\n const results = await createPropertyFromProps(this.context, itemKey, sourceProperty);\r\n if (results.errorMessage !== undefined) {\r\n return { itemKey, errorMessage: results.errorMessage };\r\n }\r\n } else {\r\n const targetProperty = (await targetItem.getProperty(change.ecTypeName))!;\r\n const results = await mergePropertyAttributeValueChanges(this.context, targetProperty, change.propertyValueChanges);\r\n if (results.errorMessage !== undefined) {\r\n return { itemKey, errorMessage: results.errorMessage };\r\n }\r\n }\r\n\r\n const mergeResults = await mergeCustomAttributes(this.context, change.customAttributeChanges.values(), async (ca) => {\r\n return this.context.editor.entities.addCustomAttributeToProperty(itemKey, change.ecTypeName, ca);\r\n });\r\n\r\n if (mergeResults.errorMessage !== undefined) {\r\n return { itemKey, errorMessage: mergeResults.errorMessage};\r\n }\r\n }\r\n return { itemKey };\r\n }\r\n\r\n // First pass to create missing changes\r\n public static async mergeItemStubChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>) {\r\n const merger = new this(context);\r\n\r\n for (const change of classChanges) {\r\n const sourceItem = (await change.schema.getItem<ECClass>(change.ecTypeName))!;\r\n const targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\r\n const changeType = change.schemaItemMissing?.changeType;\r\n\r\n if (changeType === ChangeType.Missing) {\r\n\r\n if (await context.targetSchema.lookupItem<ECClass>(targetItemKey) !== undefined) {\r\n throw new Error(`Merged schema already contains a class '${change.ecTypeName}'.`);\r\n }\r\n\r\n await merger.handleError(merger.create(context.targetSchema.schemaKey, sourceItem));\r\n }\r\n }\r\n }\r\n\r\n // 2nd pass to merge baseClass, properties, mixins and CA.\r\n public static async mergeItemContentChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>){\r\n const merger = new this(context);\r\n for (const change of classChanges) {\r\n const targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\r\n const changeType = change.schemaItemMissing?.changeType;\r\n\r\n if (change.baseClassDelta !== undefined) {\r\n await merger.handleError(merger.setBaseClass(targetItemKey, change.baseClassDelta, changeType));\r\n }\r\n\r\n // merge class attributes\r\n await merger.handleError(merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges));\r\n\r\n // merge class mixins/constraints/etc\r\n await merger.handleError(merger.merge(targetItemKey, change));\r\n\r\n // merge class property attribute values\r\n if (change.propertyChanges.size > 0) {\r\n await merger.handleError(merger.mergePropertyChanges(targetItemKey, change.propertyChanges.values()));\r\n }\r\n\r\n // merge custom attributes\r\n await merger.handleError(mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\r\n return merger.context.editor.entities.addCustomAttribute(targetItemKey, ca);\r\n }));\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG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,CAAC,CAAC,CAAC;YAExG,qCAAqC;YACrC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;YAE9D,wCAAwC;YACxC,IAAI,MAAM,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE;gBACnC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,oBAAoB,CAAC,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;aACvG;YAED,0BAA0B;YAC1B,MAAM,MAAM,CAAC,WAAW,CAAC,IAAA,6CAAqB,EAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;gBAClH,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YAC9E,CAAC,CAAC,CAAC,CAAC;SACL;IACH,CAAC;CACF;AAlMD,kCAkMC","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 { ECClass, ECClassModifier, parseClassModifier, Property, SchemaItemKey, SchemaItemType, schemaItemTypeToString, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { MutableClass } from \"../Editing/Mutable/MutableClass\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { BaseClassDelta, ChangeType, ClassChanges, PropertyChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\nimport { createPropertyFromProps, mergePropertyAttributeValueChanges } from \"./PropertyMerger\";\n\n/**\n * @internal\n */\nexport class ClassMerger<TClass extends ECClass> {\n protected readonly context: SchemaMergeContext;\n\n constructor(context: SchemaMergeContext) {\n this.context = context;\n }\n\n protected async create(_schemaKey: SchemaKey, ecClass: TClass): Promise<SchemaItemEditResults> {\n return { errorMessage: `${schemaItemTypeToString(ecClass.schemaItemType)} class type is not implemented.`};\n }\n\n protected async merge(itemKey: SchemaItemKey, _change: ClassChanges): Promise<SchemaItemEditResults> {\n return { itemKey };\n }\n\n protected async mergeAttributes(ecClass: TClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const mutableClass = ecClass as unknown as MutableClass;\n switch(attributeName) {\n case \"schemaItemType\":\n if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {\n return { errorMessage: `Changing the class '${ecClass.name}' type is not supported.` };\n }\n return true;\n\n case \"label\":\n mutableClass.setDisplayLabel(attributeNewValue);\n return true;\n\n case \"description\":\n mutableClass.setDescription(attributeNewValue);\n return true;\n\n case \"modifier\":\n const modifier = parseClassModifier(attributeNewValue);\n if (modifier === undefined) {\n return { errorMessage: \"An invalid class modifier has been provided.\" };\n }\n\n if (attributeOldValue === undefined || modifier === ECClassModifier.None) {\n mutableClass.setModifier(modifier);\n return true;\n }\n return { errorMessage: `Changing the class '${ecClass.name}' modifier is not supported.` };\n }\n return false;\n }\n\n protected isSchemaItemEditResults(obj: any): obj is SchemaItemEditResults {\n return typeof obj === \"object\" && \"errorMessage\" in obj;\n }\n\n private async setBaseClass(itemKey: SchemaItemKey, baseClassDelta: BaseClassDelta, changeType?: ChangeType): Promise<SchemaItemEditResults> {\n const [sourceBaseClass, targetBaseClass] = baseClassDelta.diagnostic.messageArgs! as [ECClass, ECClass];\n if (sourceBaseClass !== undefined) {\n const baseClassKey = new SchemaItemKey(sourceBaseClass.name, sourceBaseClass.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : sourceBaseClass.schema.schemaKey);\n\n if (changeType === ChangeType.Missing && targetBaseClass === undefined) {\n if (sourceBaseClass.schemaItemType === SchemaItemType.EntityClass) {\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\n } else if (sourceBaseClass.schemaItemType === SchemaItemType.Mixin) {\n return this.context.editor.mixins.setMixinBaseClass(itemKey, baseClassKey);\n }\n }\n\n if (targetBaseClass !== undefined) {\n const baseClass = await this.context.targetSchema.lookupItem<ECClass>(baseClassKey);\n if (baseClass === undefined) {\n return { errorMessage: `'${baseClassKey.name}' class could not be located in the merged schema.`};\n }\n if (await baseClass.is(targetBaseClass)) {\n if (baseClass.schemaItemType === SchemaItemType.EntityClass) {\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\n } else if (baseClass.schemaItemType === SchemaItemType.Mixin) {\n return this.context.editor.mixins.setMixinBaseClass(itemKey, baseClassKey);\n }\n }\n }\n }\n return { errorMessage: `Changing the class '${itemKey.name}' baseClass is not supported.`};\n }\n\n private async mergeAttributeValueChanges(itemKey: SchemaItemKey, propertyValueChanges: PropertyValueChange[]): Promise<SchemaItemEditResults> {\n if (propertyValueChanges.length > 0) {\n\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\n if (targetItem === undefined) {\n return { errorMessage: `'${itemKey.name}' class could not be located in the merged schema.` };\n }\n\n for (const change of propertyValueChanges) {\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\n const results = await this.mergeAttributes(targetItem, attributeName, attributeNewValue, attributeOldValue);\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n }\n }\n\n return { itemKey };\n }\n\n private async handleError(callback: Promise<SchemaItemEditResults>) {\n const result = await callback;\n if (result.errorMessage) {\n throw new Error(result.errorMessage);\n }\n }\n\n private async mergePropertyChanges(itemKey: SchemaItemKey, propertyChanges: Iterable<PropertyChanges>): Promise<SchemaItemEditResults> {\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\n if (targetItem === undefined) {\n return { itemKey, errorMessage: `'${itemKey.name}' class could not be located in the merged schema.`};\n }\n\n for (const change of propertyChanges) {\n if (change.propertyMissing?.changeType === ChangeType.Missing) {\n if (await targetItem.getProperty(change.ecTypeName) !== undefined) {\n return { itemKey, errorMessage: `Merged schema already contains a class '${itemKey.name}' property '${change.ecTypeName}'.`};\n }\n\n const sourceProperty = change.propertyMissing.diagnostic.ecDefinition as unknown as Property;\n const results = await createPropertyFromProps(this.context, itemKey, sourceProperty);\n if (results.errorMessage !== undefined) {\n return { itemKey, errorMessage: results.errorMessage };\n }\n } else {\n const targetProperty = (await targetItem.getProperty(change.ecTypeName))!;\n const results = await mergePropertyAttributeValueChanges(this.context, targetProperty, change.propertyValueChanges);\n if (results.errorMessage !== undefined) {\n return { itemKey, errorMessage: results.errorMessage };\n }\n }\n\n const mergeResults = await mergeCustomAttributes(this.context, change.customAttributeChanges.values(), async (ca) => {\n return this.context.editor.entities.addCustomAttributeToProperty(itemKey, change.ecTypeName, ca);\n });\n\n if (mergeResults.errorMessage !== undefined) {\n return { itemKey, errorMessage: mergeResults.errorMessage};\n }\n }\n return { itemKey };\n }\n\n // First pass to create missing changes\n public static async mergeItemStubChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>) {\n const merger = new this(context);\n\n for (const change of classChanges) {\n const sourceItem = (await change.schema.getItem<ECClass>(change.ecTypeName))!;\n const targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\n const changeType = change.schemaItemMissing?.changeType;\n\n if (changeType === ChangeType.Missing) {\n\n if (await context.targetSchema.lookupItem<ECClass>(targetItemKey) !== undefined) {\n throw new Error(`Merged schema already contains a class '${change.ecTypeName}'.`);\n }\n\n await merger.handleError(merger.create(context.targetSchema.schemaKey, sourceItem));\n }\n }\n }\n\n // 2nd pass to merge baseClass, properties, mixins and CA.\n public static async mergeItemContentChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>){\n const merger = new this(context);\n for (const change of classChanges) {\n const targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\n const changeType = change.schemaItemMissing?.changeType;\n\n if (change.baseClassDelta !== undefined) {\n await merger.handleError(merger.setBaseClass(targetItemKey, change.baseClassDelta, changeType));\n }\n\n // merge class attributes\n await merger.handleError(merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges));\n\n // merge class mixins/constraints/etc\n await merger.handleError(merger.merge(targetItemKey, change));\n\n // merge class property attribute values\n if (change.propertyChanges.size > 0) {\n await merger.handleError(merger.mergePropertyChanges(targetItemKey, change.propertyChanges.values()));\n }\n\n // merge custom attributes\n await merger.handleError(mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\n return merger.context.editor.entities.addCustomAttribute(targetItemKey, ca);\n }));\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,kGAAkG;AAClG,gEAAgE;AAChE,yDAA6E;AAE7E;;GAEG;AACH,MAAqB,eAAgB,SAAQ,mCAA0B;IACrE;;OAEG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,UAAU,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;gBAChD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,+EAA+E;gBAC/E,iEAAiE;gBACjE,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAClF,IAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACvE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,cAAc,EAAE,CAAC;iBACxD;gBACD,OAAO,kBAAkB,CAAC;YAC5B,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;oBACtE,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;iBACjG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;oBAC1E,MAAM,IAAI,KAAK,CAAC,oDAAoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","sourcesContent":["// /*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,kGAAkG;AAClG,gEAAgE;AAChE,yDAA6E;AAE7E;;GAEG;AACH,MAAqB,eAAgB,SAAQ,mCAA0B;IACrE;;OAEG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,UAAU,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;gBAChD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,+EAA+E;gBAC/E,iEAAiE;gBACjE,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAClF,IAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACvE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,cAAc,EAAE,CAAC;iBACxD;gBACD,OAAO,kBAAkB,CAAC;YAC5B,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;oBACtE,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;iBACjG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;oBAC1E,MAAM,IAAI,KAAK,CAAC,oDAAoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","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 { Constant, SchemaItem } from \"@itwin/ecschema-metadata\";\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\n\n/**\n * @internal\n */\nexport default class ConstantsMerger extends SchemaItemMerger<Constant> {\n /**\n * Creates the property value resolver for [[Constant]] items.\n */\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<Constant>> {\n return {\n phenomenon: (phenomenonFullName, targetItemKey) => {\n // There are two options, either the phenomenon was referenced from another\n // schema or it is defined in the same schema as the constant to be merged.\n // In the latter case, the changes would report a different property value that\n // refers to the source schema. So that needs to be changed here.\n const [schemaName, phenomenonName] = SchemaItem.parseFullName(phenomenonFullName);\n if(this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\n return `${targetItemKey.schemaName}.${phenomenonName}`;\n }\n return phenomenonFullName;\n },\n numerator: (value, targetItemKey) => {\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\n if(item !== undefined && item.hasNumerator && item.numerator !== value) {\n throw new Error(`Failed to merged, constant numerator conflict: ${value} -> ${item.numerator}`);\n }\n return value;\n },\n denominator: (value, targetItemKey) => {\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\n if(item !== undefined && item.hasDenominator && item.denominator !== value) {\n throw new Error(`Failed to merged, constant denominator conflict: ${value} -> ${item.denominator}`);\n }\n return value;\n },\n };\n }\n}\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAuH;AACvH,+DAA0F;AAO1F;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CAAC,YAAgC,EAAE,OAAkD,EAAE,QAAoE;IACpM,KAAK,MAAM,8BAA8B,IAAI,OAAO,EAAE;QACpD,KAAK,MAAM,MAAM,IAAI,8BAA8B,CAAC,sBAAsB,EAAE;YAC1E,IAAI,MAAM,CAAC,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAC5C,MAAM,CAAC,qBAAqB,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,WAAgC,CAAC;gBACnF,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAI,8BAAU,CAAC,aAAa,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;gBAC1F,MAAM,aAAa,GAAG,IAAI,iCAAa,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC;oBAC7G,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS;oBACrC,CAAC,CAAC,IAAI,6BAAS,CAAC,UAAU,CAAC,CAC5B,CAAC;gBACF,MAAM,qBAAqB,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,UAAU,CAAuB,aAAa,CAAC,CAAC;gBAC9G,IAAI,qBAAqB,KAAK,SAAS,EAAE;oBACvC,OAAO,EAAE,YAAY,EAAE,+CAA+C,aAAa,CAAC,IAAI,wBAAwB,EAAC,CAAC;iBACnH;gBAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC;oBAC7B,GAAG,qBAAqB;oBACxB,SAAS,EAAE,qBAAqB,CAAC,QAAQ;iBAC1C,CAAC,CAAC;gBAEH,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;oBACtC,OAAO,EAAG,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;iBAChD;aACF;iBAAM;gBACL,OAAO,EAAE,YAAY,EAAE,+BAA+B,8BAA8B,CAAC,UAAU,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,4BAA4B,EAAC,CAAC;aACnK;SACF;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,sDA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAuH;AACvH,+DA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CAAC,IAAI,4BAA4B,EAAC,CAAC;aACnK;SACF;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,sDA6BC","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 Merging\n */\n\nimport { CustomAttribute, CustomAttributeClass, SchemaItem, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ChangeType, CustomAttributeContainerChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\ninterface EditResults {\n errorMessage?: string;\n}\n\n/**\n * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass\n * a scope (Class, Property, Schema) specific handler.\n * @param mergeContext The current schema merging context.\n * @param changes An iterable with custom attribute changes.\n * @param callback The callback to add the custom attribute with a scope specific editor.\n * @returns A EditResults object.\n * @internal\n */\nexport async function mergeCustomAttributes(mergeContext: SchemaMergeContext, changes: Iterable<CustomAttributeContainerChanges>, callback: (customAttribute: CustomAttribute) => Promise<EditResults>): Promise<EditResults> {\n for (const customAttributeContainerChange of changes) {\n for (const change of customAttributeContainerChange.customAttributeChanges) {\n if (change.changeType === ChangeType.Missing) {\n const [sourceCustomAttribute] = change.diagnostic.messageArgs as [CustomAttribute];\n const [schemaName, itemName] = SchemaItem.parseFullName(sourceCustomAttribute.className);\n const schemaItemKey = new SchemaItemKey(itemName, mergeContext.sourceSchema.schemaKey.compareByName(schemaName)\n ? mergeContext.targetSchema.schemaKey\n : new SchemaKey(schemaName),\n );\n const targetCustomAttribute = await mergeContext.targetSchema.lookupItem<CustomAttributeClass>(schemaItemKey);\n if (targetCustomAttribute === undefined) {\n return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`};\n }\n\n const results = await callback({\n ...sourceCustomAttribute,\n className: targetCustomAttribute.fullName,\n });\n\n if (results.errorMessage !== undefined) {\n return { errorMessage: results.errorMessage };\n }\n } else {\n return { errorMessage: `Changes of Custom Attribute ${customAttributeContainerChange.ecTypeName} on ${mergeContext.targetSchema.name} merge is not implemented.`};\n }\n }\n }\n return {};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;AAE5C,+DAAuE;AAEvE;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAClD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxF,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,OAAqB;QAC1E,IAAI,OAAO,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,EAAE;YACvC,IAAI,OAAO,CAAC,iBAAiB,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAChE,OAAO,EAAE,YAAY,EAAE,8BAA8B,OAAO,CAAC,IAAI,4BAA4B,EAAC,CAAC;aAChG;YAED,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE;gBACxD,KAAK,MAAM,iBAAiB,IAAI,MAAM,CAAC,iBAAiB,EAAE;oBACxD,MAAM,MAAM,GAAG,iBAAiB,CAAC,UAAU,CAAC,WAAkC,CAAC;oBAC/E,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;wBAC1B,MAAM,QAAQ,GAAG,IAAI,iCAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;4BAChH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;4BACrC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;wBAC5B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;wBAC9E,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE;4BACrC,OAAO,MAAM,CAAC;yBACf;qBACF;iBACF;aACF;SACF;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF;AA5BD,oCA4BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;AAE5C,+DAAuE;AAEvE;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAClD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxF,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,OAAqB;QAC1E,IAAI,OAAO,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,EAAE;YACvC,IAAI,OAAO,CAAC,iBAAiB,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAChE,OAAO,EAAE,YAAY,EAAE,8BAA8B,OAAO,CAAC,IAAI,4BAA4B,EAAC,CAAC;aAChG;YAED,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE;gBACxD,KAAK,MAAM,iBAAiB,IAAI,MAAM,CAAC,iBAAiB,EAAE;oBACxD,MAAM,MAAM,GAAG,iBAAiB,CAAC,UAAU,CAAC,WAAkC,CAAC;oBAC/E,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;wBAC1B,MAAM,QAAQ,GAAG,IAAI,iCAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;4BAChH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;4BACrC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;wBAC5B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;wBAC9E,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE;4BACrC,OAAO,MAAM,CAAC;yBACf;qBACF;iBACF;aACF;SACF;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF;AA5BD,oCA4BC","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 { EntityClass, Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ChangeType, ClassChanges } from \"../Validation/SchemaChanges\";\n\n/**\n * @internal\n */\nexport default class EntityClassMerger extends ClassMerger<EntityClass> {\n protected override async create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults> {\n return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);\n }\n\n protected override async merge(itemKey: SchemaItemKey, changes: ClassChanges): Promise<SchemaItemEditResults> {\n if (changes.entityMixinChanges.size > 0) {\n if (changes.schemaItemMissing?.changeType !== ChangeType.Missing) {\n return { errorMessage: `Changing the entity class '${itemKey.name}' mixins is not supported.`};\n }\n\n for (const change of changes.entityMixinChanges.values()) {\n for (const entityMixinChange of change.entityMixinChange) {\n const mixins = entityMixinChange.diagnostic.messageArgs! as unknown as [Mixin];\n for (const mixin of mixins) {\n const mixinKey = new SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : mixin.schema.schemaKey);\n const result = await this.context.editor.entities.addMixin(itemKey, mixinKey);\n if (result.errorMessage !== undefined) {\n return result;\n }\n }\n }\n }\n }\n return { itemKey };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAKA,+DAA6E;AAC7E,yDAAsD;AAItD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,mCAA6B;IAE1E,qDAAqD;IACrD,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAmB,EAAE,OAA2B;QACrG,KAAK,MAAM,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE;YACjE,4EAA4E;YAC5E,wCAAwC;YACxC,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAEzE,MAAM,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;gBAC3E,IAAI,UAAU,KAAK,SAAS,EAAE;oBAC5B,MAAM,KAAK,CAAC,eAAe,gBAAgB,CAAC,UAAU,wBAAwB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAClG;gBAED,4EAA4E;gBAC5E,+DAA+D;gBAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAEtD,8EAA8E;gBAC9E,gFAAgF;gBAChF,SAAS;aACV;YAED,6EAA6E;YAC7E,4EAA4E;YAC5E,8EAA8E;YAC9E,KAAI,MAAM,eAAe,IAAI,gBAAgB,CAAC,gBAAgB,EAAE;gBAC9D,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,eAAe,CAAC,UAAU,CAAC,WAAmC,CAAC,CAAC;aAC5G;SACF;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,OAAsB,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,CAAsB;QACjH,8EAA8E;QAC9E,oEAAoE;QACpE,IAAG,YAAY,KAAK,OAAO,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,qDAAqD,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAAC;SAChH;QAED,gFAAgF;QAChF,iFAAiF;QACjF,IAAG,YAAY,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,EAAE;YAClD,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACxE;QACD,IAAG,YAAY,KAAK,aAAa,IAAI,KAAK,KAAK,SAAS,EAAE;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;A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,CAAC,qDAAqD,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAAC;SAChH;QAED,gFAAgF;QAChF,iFAAiF;QACjF,IAAG,YAAY,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,EAAE;YAClD,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACxE;QACD,IAAG,YAAY,KAAK,aAAa,IAAI,KAAK,KAAK,SAAS,EAAE;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","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 { AnyEnumerator, Enumeration, SchemaItemKey} from \"@itwin/ecschema-metadata\";\nimport { ChangeType, EnumerationChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\n\ntype EnumeratorDeltaArgs = [AnyEnumerator, keyof AnyEnumerator, string | undefined];\n\n/**\n * @internal\n */\nexport default class EnumerationMerger extends SchemaItemMerger<Enumeration> {\n\n /** Shorthand property to the enumerations editor. */\n private get _editor() {\n return this.context.editor.enumerations;\n }\n\n protected override async merge(itemKey: SchemaItemKey, source: Enumeration, changes: EnumerationChanges) {\n for (const enumeratorChange of changes.enumeratorChanges.values()) {\n // In case the enumerator entry does not exist in the target enumeration the\n // enumeratorMissing property is set and\n if (enumeratorChange.enumeratorMissing?.changeType === ChangeType.Missing) {\n\n const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);\n if (enumerator === undefined) {\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in class ${source.fullName}`);\n }\n\n // Enumerators are plain javascript objects with out any references to other\n // instances or a schema. That allows to simply copy them over.\n await this._editor.addEnumerator(itemKey, enumerator);\n\n // Since every missing enumerator has delta changes for ech property, the loop\n // must call continue here to avoid having all properties checked and set again.\n continue;\n }\n\n // For changes where the enumerators differ, the enumeratorDeltas property is\n // filled. This allows to change individual enumerator entries. This is only\n // allowed for labels and descriptions, all other deltas would throw an error.\n for(const enumeratorDelta of enumeratorChange.enumeratorDeltas) {\n await this.mergeEnumeratorChanges(itemKey, enumeratorDelta.diagnostic.messageArgs! as EnumeratorDeltaArgs);\n }\n }\n }\n\n private async mergeEnumeratorChanges(itemKey: SchemaItemKey, [enumerator, propertyName, value]: EnumeratorDeltaArgs) {\n // In case an enumerator has the same name but different value, the enumerator\n // cannot be merged to keep integrity for the existing schema users.\n if(propertyName === \"value\") {\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${enumerator.name}\" has different values.`);\n }\n\n // For the other two properties they shall only be merged if the source value is\n // set. In case they'd be undefined, the current enumerators value shall be kept.\n if(propertyName === \"label\" && value !== undefined) {\n await this._editor.setEnumeratorLabel(itemKey, enumerator.name, value);\n }\n if(propertyName === \"description\" && value !== undefined) {\n await this._editor.setEnumeratorDescription(itemKey, enumerator.name, value);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiI;AACjI,yDAA6E;AAG7E;;GAEG;AACH,MAAqB,oBAAqB,SAAQ,mCAAgC;IAE7D,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAsB,EAAE,OAA8B;QAC3G,KAAK,MAAM,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,CAAC,MAAM,EAAE,EAAE;YAC7E,KAAK,MAAM,MAAM,IAAI,sBAAsB,CAAC,sBAAsB,EAAE;gBAClE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,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AAK,SAAS,EAAE;wBAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,IAAI,wBAAwB,CAAC,CAAC;qBAC3F;oBACD,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;iBACxG;aACF;SACF;IACH,CAAC;IAED;;;OAGG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,eAAe,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE;gBACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,QAAQ,EAAE;oBACnD,MAAM,IAAI,KAAK,CAAC,kCAAkC,aAAa,CAAC,IAAI,qCAAqC,CAAC,CAAC;iBAC5G;gBACD,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACxE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;iBAClD;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAvDD,uCAuDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiI;AACjI,yDAA6E;AAG7E;;GAEG;AACH,MAAqB,oBAAqB,SAAQ,mCAAgC;IAE7D,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAsB,EAAE,OAA8B;QAC3G,KAAK,MAAM,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,CAAC,MA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AAS,CAAC,CAAC;iBAC9G;qBAAM;oBACL,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAS,MAAM,CAAC,CAAC;oBACvD,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,IAAI,wBAAwB,CAAC,CAAC;qBAC3F;oBACD,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;iBACxG;aACF;SACF;IACH,CAAC;IAED;;;OAGG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,eAAe,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE;gBACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,QAAQ,EAAE;oBACnD,MAAM,IAAI,KAAK,CAAC,kCAAkC,aAAa,CAAC,IAAI,qCAAqC,CAAC,CAAC;iBAC5G;gBACD,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACxE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;iBAClD;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAvDD,uCAuDC","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 { Format, InvertedUnit, KindOfQuantity, OverrideFormat, SchemaItem, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\nimport { KindOfQuantityChanges } from \"../Validation/SchemaChanges\";\n\n/**\n * @internal\n */\nexport default class KindOfQuantityMerger extends SchemaItemMerger<KindOfQuantity> {\n\n protected override async merge(itemKey: SchemaItemKey, source: KindOfQuantity, changes: KindOfQuantityChanges) {\n for (const presentationUnitChange of changes.presentationUnitChanges.values()) {\n for (const change of presentationUnitChange.presentationUnitChange) {\n const format = change.diagnostic.messageArgs![0];\n const isDefault = source.defaultPresentationFormat === format;\n\n if (OverrideFormat.isOverrideFormat(format)) {\n const parentFormat = await this.lookup<Format>(format.parent);\n if (parentFormat === undefined) {\n throw new Error(`Unable to locate the format class ${format.parent.name} in the merged schema.`);\n }\n\n const unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined = [];\n if (format.units !== undefined) {\n for (const [unit, label] of format.units) {\n const targetUnit = await this.lookup<Unit | InvertedUnit>(unit);\n if (targetUnit === undefined) {\n throw new Error(`Unable to locate the unit class ${unit.name} in the merged schema.`);\n }\n unitAndLabels.push([targetUnit, label]);\n }\n }\n const overrideFormat = await this.context.editor.kindOfQuantities.createFormatOverride(itemKey, parentFormat.key, format.precision, unitAndLabels);\n await this.context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, overrideFormat, isDefault);\n } else {\n const targetFormat = await this.lookup<Format>(format);\n if (targetFormat === undefined) {\n throw new Error(`Unable to locate the format class ${format.name} in the merged schema.`);\n }\n await this.context.editor.kindOfQuantities.addPresentationFormat(itemKey, targetFormat.key, isDefault);\n }\n }\n }\n }\n\n /**\n *\n * Creates the property value resolver for [[KindOfQuantity]] items.\n */\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<KindOfQuantity>> {\n return {\n persistenceUnit: (newValue, targetItemKey, oldValue) => {\n if (oldValue !== undefined && oldValue !== newValue) {\n throw new Error(`Changing the kind of quantity '${targetItemKey.name}' persistenceUnit is not supported.`);\n }\n const [schemaName, itemName] = SchemaItem.parseFullName(newValue);\n if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\n return `${targetItemKey.schemaName}.${itemName}`;\n }\n return newValue;\n },\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA2E;AAE3E,+CAA4C;AAE5C;;GAEG;AACH,MAAqB,WAAY,SAAQ,yBAAkB;IAEtC,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAc;QAClE,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;YACnC,OAAO,EAAE,YAAY,EAAE,aAAa,OAAO,CAAC,QAAQ,iDAAiD,EAAE,CAAC;SACzG;QAED,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;YAClI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAAc,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC5H,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,EAAE;oBACnC,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,EAAE,CAAC;iBAC7F;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAC7F,CAAC;CACF;AAvBD,8BAuBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA2E;AAE3E,+CAA4C;AAE5C;;GAEG;AACH,MAAqB,WAAY,SAAQ,yBAAkB;IAEtC,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAc;QAClE,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;YACnC,OAAO,EAAE,YAAY,EAAE,aAAa,OAAO,CAAC,QAAQ,iDAAiD,EAAE,CAAC;SACzG;QAED,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;YAClI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAAc,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC5H,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,EAAE;oBACnC,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,EAAE,CAAC;iBAC7F;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAC7F,CAAC;CACF;AAvBD,8BAuBC","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 { Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ClassMerger } from \"./ClassMerger\";\n\n/**\n * @internal\n */\nexport default class MixinMerger extends ClassMerger<Mixin> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: Mixin): Promise<SchemaItemEditResults> {\n if (ecClass.appliesTo === undefined) {\n return { errorMessage: `The Mixin ${ecClass.fullName} is missing the required 'appliesTo' attribute.` };\n }\n\n const appliesTo = new SchemaItemKey(ecClass.appliesTo.name, this.context.sourceSchema.schemaKey.matches(ecClass.appliesTo.schemaKey)\n ? this.context.targetSchema.schemaKey\n : ecClass.appliesTo.schemaKey);\n return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);\n }\n\n protected override async mergeAttributes(ecClass: Mixin, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n switch(attributeName) {\n case \"appliesTo\":\n if (attributeOldValue !== undefined) {\n return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };\n }\n return true;\n }\n return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\n }\n}\n"]}
|