@itwin/ecschema-editing 5.0.0-dev.89 → 5.0.0-dev.90

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.
@@ -82,6 +82,5 @@ export declare class ECClasses extends SchemaItems {
82
82
  setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<void>;
83
83
  private getClass;
84
84
  protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): void;
85
- private findDerivedClasses;
86
85
  }
87
86
  //# sourceMappingURL=ECClasses.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ECClasses.d.ts","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,eAAe,EACf,6BAA6B,EAE7B,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,2BAA2B,EAC3E,sBAAsB,EAAE,aAAa,EAAc,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,wBAAwB,EACrH,WAAW,EAAE,mBAAmB,EACjC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGzH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,GAAG,cAAc,CAAC,iBAAiB,GAAG,cAAc,CAAC,KAAK,GAAG,cAAc,CAAC,oBAAoB,CAAC;AAEzL;;;GAGG;AACH,qBAAa,SAAU,SAAQ,WAAW;IAExC,SAAS,aAAa,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB;IAU3F,UAAmB,cAAc,EAAE,kBAAkB,CAAC;IAEtD;;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3D;;;;OAIG;IACU,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBzG;;;;OAIG;IACU,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;YAsBhF,QAAQ;IAatB,SAAS,CAAC,qBAAqB,CAAC,SAAS,EAAE,6BAA6B,EAAE,eAAe,EAAE,eAAe;CAK3G"}
@@ -290,20 +290,6 @@ class ECClasses extends SchemaItems_1.SchemaItems {
290
290
  const map = container.customAttributes;
291
291
  map.delete(customAttribute.className);
292
292
  }
293
- async findDerivedClasses(mutableClass) {
294
- const derivedClasses = [];
295
- const schemaItems = this.schemaEditor.schemaContext.getSchemaItems();
296
- let { value, done } = schemaItems.next();
297
- while (!done) {
298
- if (await value.is(mutableClass)) {
299
- if (!mutableClass.key.matches(value.key)) {
300
- derivedClasses.push(value);
301
- }
302
- }
303
- ({ value, done } = schemaItems.next());
304
- }
305
- return derivedClasses;
306
- }
307
293
  }
308
294
  exports.ECClasses = ECClasses;
309
295
  function isMutableClass(schemaItem) {
@@ -1 +1 @@
1
- {"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAOkC;AAClC,sDAA6C;AAG7C,+CAA+C;AAC/C,6CAAyH;AACzH,2CAAkI;AAElI,+CAA8D;AAI9D;;;GAGG;AACH,MAAa,SAAU,SAAQ,yBAAW;IAExC,YAAsB,cAAkC,EAAE,YAAiC;QACzF,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;QACpC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACzE,IAAI,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,cAAc,GAAwB,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QACrE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;QACzC,OAAO,CAAC,IAAI,EAAE,CAAC;YACb,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;gBACjC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;oBACzC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;YACD,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AA1TD,8BA0TC;AAED,SAAS,cAAc,CAAC,UAAsB;IAC5C,OAAO,2BAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n CustomAttribute,\n CustomAttributeContainerProps,\n DelayedPromiseWithProps,\n ECClass, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\n PrimitivePropertyProps, PrimitiveType, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, StructArrayPropertyProps,\n StructClass, StructPropertyProps,\n} from \"@itwin/ecschema-metadata\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { ArrayProperties, EnumerationProperties, PrimitiveProperties, Properties, StructProperties } from \"./Properties\";\nimport { ClassId, CustomAttributeId, ECEditingStatus, PropertyId, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\nimport { CreateSchemaItem, SchemaItems } from \"./SchemaItems\";\n\nexport type ECClassSchemaItems = SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.RelationshipClass | SchemaItemType.Mixin | SchemaItemType.CustomAttributeClass;\n\n/**\n * @alpha\n * Acts as a base class for schema class creation. Enables property creation.\n */\nexport class ECClasses extends SchemaItems{\n\n protected constructor(schemaItemType: ECClassSchemaItems, schemaEditor: SchemaContextEditor) {\n super(schemaItemType, schemaEditor);\n this.schemaItemType = schemaItemType;\n this.properties = new Properties(this.schemaItemType, this.schemaEditor);\n this.arrayProperties = new ArrayProperties(this.schemaItemType, this.schemaEditor);\n this.primitiveProperties = new PrimitiveProperties(this.schemaItemType, this.schemaEditor);\n this.enumerationProperties = new EnumerationProperties(this.schemaItemType, this.schemaEditor);\n this.structProperties = new StructProperties(this.schemaItemType, this.schemaEditor);\n }\n\n protected override schemaItemType: ECClassSchemaItems;\n\n /**\n * Allows access for the editors itemType class instance.\n * It returns ECClass here, but editors for subclasses will override this to return the\n * appropriate subclass.\n */\n protected override get itemTypeClass(): typeof ECClass {\n return ECClass;\n }\n\n /**\n * Allows access for editing of base Property attributes.\n */\n public readonly properties: Properties;\n /**\n * Allows access for editing of ArrayProperty attributes.\n */\n public readonly arrayProperties: ArrayProperties;\n /**\n * Allows access for editing of PrimitiveProperty attributes.\n */\n public readonly primitiveProperties: PrimitiveProperties;\n /**\n * Allows access for editing of EnumerationProperty attributes.\n */\n public readonly enumerationProperties: EnumerationProperties;\n /**\n * Allows access for editing of StructProperty attributes.\n */\n public readonly structProperties: StructProperties;\n\n public async createClass<T extends ECClass>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, baseClassKey?: SchemaItemKey, ...args: any[]): Promise<T> {\n const newClass = await this.createSchemaItem(schemaKey, type, create, name, ...args);\n\n if (baseClassKey !== undefined) {\n if(!await this.schemaEditor.schemaContext.getSchema(baseClassKey.schemaKey)) {\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(baseClassKey.schemaKey));\n }\n\n const baseClassItem = await this.getSchemaItem(baseClassKey, this.itemTypeClass);\n await (newClass as ECClass as MutableClass).setBaseClass(new DelayedPromiseWithProps<SchemaItemKey, T>(baseClassKey, async () => baseClassItem as T));\n }\n\n return newClass;\n }\n\n /**\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\n * property type to primitives of type Double, String, DateTime and Integer.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<void> {\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\n && type !== PrimitiveType.Integer)\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\n\n if (\"\" === prefix)\n throw new Error(\"The specified property name prefix is invalid\");\n\n const prefixedName = `${prefix}_${name}`;\n\n const mutableClass = await this.getClass(classKey);\n\n await mutableClass.createPrimitiveProperty(prefixedName, type);\n }\n\n /**\n * Create a primitive property on class identified by the given SchemaItemKey.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createPrimitiveProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitivePropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\n if (enumSchemaItemKey === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(SchemaItemType.Enumeration, type.name, mutableClass.schema.schemaKey));\n\n await mutableClass.createPrimitiveProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(enumProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createPrimitiveArrayProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationArrayProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createPrimitiveArrayProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, props: PrimitiveArrayPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(props);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createStructProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createStructProperty(name, type);\n await newProperty.fromJSON(structProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createStructArrayProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\n await newProperty.fromJSON(structProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.deleteProperty(name);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.DeleteProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async delete(classKey: SchemaItemKey): Promise<void> {\n try {\n const schema = await this.getSchema(classKey.schemaKey);\n const ecClass = await schema.getItem(classKey.name, this.itemTypeClass);\n if (ecClass === undefined)\n return;\n\n await schema.deleteClass(ecClass.name);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.DeleteClass, new ClassId(this.schemaItemType, classKey), e);\n }\n }\n\n /**\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\n * @param classKey The SchemaItemKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n mutableClass.addCustomAttribute(customAttribute);\n\n const diagnosticIterable = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of diagnosticIterable) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeCustomAttribute(mutableClass, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, mutableClass), undefined, diagnostics);\n }\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToClass, new ClassId(this.schemaItemType, classKey), e);\n }\n }\n\n /**\n * Sets the base class of a SchemaItem.\n * @param itemKey The SchemaItemKey of the Item.\n * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.\n */\n public async setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<void> {\n try {\n const classItem = await this.getSchemaItem(itemKey, this.itemTypeClass);\n if (!baseClassKey) {\n await (classItem as MutableClass).setBaseClass(undefined);\n return;\n }\n\n if(!await this.schemaEditor.schemaContext.getSchema(baseClassKey.schemaKey)) {\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(baseClassKey.schemaKey));\n }\n\n const baseClassItem = await this.getSchemaItem(baseClassKey, this.itemTypeClass);\n if (classItem.baseClass !== undefined && !await baseClassItem.is(await classItem.baseClass))\n throw new SchemaEditingError(ECEditingStatus.InvalidBaseClass, new ClassId(this.schemaItemType, baseClassKey), undefined, undefined, `Base class ${baseClassKey.fullName} must derive from ${(await classItem.baseClass).fullName}.`);\n\n await (classItem as MutableClass).setBaseClass(new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClassKey, async () => baseClassItem));\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(this.schemaItemType, itemKey), e);\n }\n }\n\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\n const schema = await this.getSchema(classKey.schemaKey);\n\n const ecClass = await schema.getItem(classKey.name);\n if (ecClass === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new ClassId(this.schemaItemType, classKey));\n\n if(!isMutableClass(ecClass))\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new ClassId(this.schemaItemType, classKey));\n\n return ecClass;\n }\n\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\n assert(container.customAttributes !== undefined);\n const map = container.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\n const derivedClasses: Array<MutableClass> = [];\n const schemaItems = this.schemaEditor.schemaContext.getSchemaItems();\n let { value, done } = schemaItems.next();\n while (!done) {\n if (await value.is(mutableClass)) {\n if (!mutableClass.key.matches(value.key)) {\n derivedClasses.push(value);\n }\n }\n ({ value, done } = schemaItems.next());\n }\n\n return derivedClasses;\n }\n}\n\nfunction isMutableClass(schemaItem: SchemaItem): schemaItem is MutableClass {\n return ECClass.isECClass(schemaItem);\n}\n"]}
1
+ {"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAOkC;AAClC,sDAA6C;AAG7C,+CAA+C;AAC/C,6CAAyH;AACzH,2CAAkI;AAElI,+CAA8D;AAI9D;;;GAGG;AACH,MAAa,SAAU,SAAQ,yBAAW;IAExC,YAAsB,cAAkC,EAAE,YAAiC;QACzF,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;QACpC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACzE,IAAI,CAAC,eAAe,GAAG,IAAI,4BAAe,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACnF,IAAI,CAAC,mBAAmB,GAAG,IAAI,gCAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3F,IAAI,CAAC,qBAAqB,GAAG,IAAI,kCAAqB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/F,IAAI,CAAC,gBAAgB,GAAG,IAAI,6BAAgB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;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C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAExD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,OAAO,KAAK,SAAS;YACvB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,kBAAkB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC;QAE/G,IAAG,CAAC,cAAc,CAAC,OAAO,CAAC;YACzB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,qBAAqB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC;QAElH,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,qBAAqB,CAAC,SAAwC,EAAE,eAAgC;QACxG,IAAA,qBAAM,EAAC,SAAS,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,SAAS,CAAC,gBAAgD,CAAC;QACvE,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AA1SD,8BA0SC;AAED,SAAS,cAAc,CAAC,UAAsB;IAC5C,OAAO,2BAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n CustomAttribute,\n CustomAttributeContainerProps,\n DelayedPromiseWithProps,\n ECClass, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\n PrimitivePropertyProps, PrimitiveType, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, StructArrayPropertyProps,\n StructClass, StructPropertyProps,\n} from \"@itwin/ecschema-metadata\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { ArrayProperties, EnumerationProperties, PrimitiveProperties, Properties, StructProperties } from \"./Properties\";\nimport { ClassId, CustomAttributeId, ECEditingStatus, PropertyId, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\nimport { CreateSchemaItem, SchemaItems } from \"./SchemaItems\";\n\nexport type ECClassSchemaItems = SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.RelationshipClass | SchemaItemType.Mixin | SchemaItemType.CustomAttributeClass;\n\n/**\n * @alpha\n * Acts as a base class for schema class creation. Enables property creation.\n */\nexport class ECClasses extends SchemaItems{\n\n protected constructor(schemaItemType: ECClassSchemaItems, schemaEditor: SchemaContextEditor) {\n super(schemaItemType, schemaEditor);\n this.schemaItemType = schemaItemType;\n this.properties = new Properties(this.schemaItemType, this.schemaEditor);\n this.arrayProperties = new ArrayProperties(this.schemaItemType, this.schemaEditor);\n this.primitiveProperties = new PrimitiveProperties(this.schemaItemType, this.schemaEditor);\n this.enumerationProperties = new EnumerationProperties(this.schemaItemType, this.schemaEditor);\n this.structProperties = new StructProperties(this.schemaItemType, this.schemaEditor);\n }\n\n protected override schemaItemType: ECClassSchemaItems;\n\n /**\n * Allows access for the editors itemType class instance.\n * It returns ECClass here, but editors for subclasses will override this to return the\n * appropriate subclass.\n */\n protected override get itemTypeClass(): typeof ECClass {\n return ECClass;\n }\n\n /**\n * Allows access for editing of base Property attributes.\n */\n public readonly properties: Properties;\n /**\n * Allows access for editing of ArrayProperty attributes.\n */\n public readonly arrayProperties: ArrayProperties;\n /**\n * Allows access for editing of PrimitiveProperty attributes.\n */\n public readonly primitiveProperties: PrimitiveProperties;\n /**\n * Allows access for editing of EnumerationProperty attributes.\n */\n public readonly enumerationProperties: EnumerationProperties;\n /**\n * Allows access for editing of StructProperty attributes.\n */\n public readonly structProperties: StructProperties;\n\n public async createClass<T extends ECClass>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, baseClassKey?: SchemaItemKey, ...args: any[]): Promise<T> {\n const newClass = await this.createSchemaItem(schemaKey, type, create, name, ...args);\n\n if (baseClassKey !== undefined) {\n if(!await this.schemaEditor.schemaContext.getSchema(baseClassKey.schemaKey)) {\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(baseClassKey.schemaKey));\n }\n\n const baseClassItem = await this.getSchemaItem(baseClassKey, this.itemTypeClass);\n await (newClass as ECClass as MutableClass).setBaseClass(new DelayedPromiseWithProps<SchemaItemKey, T>(baseClassKey, async () => baseClassItem as T));\n }\n\n return newClass;\n }\n\n /**\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\n * property type to primitives of type Double, String, DateTime and Integer.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<void> {\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\n && type !== PrimitiveType.Integer)\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\n\n if (\"\" === prefix)\n throw new Error(\"The specified property name prefix is invalid\");\n\n const prefixedName = `${prefix}_${name}`;\n\n const mutableClass = await this.getClass(classKey);\n\n await mutableClass.createPrimitiveProperty(prefixedName, type);\n }\n\n /**\n * Create a primitive property on class identified by the given SchemaItemKey.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createPrimitiveProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitivePropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\n if (enumSchemaItemKey === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(SchemaItemType.Enumeration, type.name, mutableClass.schema.schemaKey));\n\n await mutableClass.createPrimitiveProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(enumProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createPrimitiveArrayProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationArrayProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createPrimitiveArrayProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, props: PrimitiveArrayPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(props);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createStructProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createStructProperty(name, type);\n await newProperty.fromJSON(structProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createStructArrayProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\n await newProperty.fromJSON(structProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.deleteProperty(name);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.DeleteProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async delete(classKey: SchemaItemKey): Promise<void> {\n try {\n const schema = await this.getSchema(classKey.schemaKey);\n const ecClass = await schema.getItem(classKey.name, this.itemTypeClass);\n if (ecClass === undefined)\n return;\n\n await schema.deleteClass(ecClass.name);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.DeleteClass, new ClassId(this.schemaItemType, classKey), e);\n }\n }\n\n /**\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\n * @param classKey The SchemaItemKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n mutableClass.addCustomAttribute(customAttribute);\n\n const diagnosticIterable = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of diagnosticIterable) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeCustomAttribute(mutableClass, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, mutableClass), undefined, diagnostics);\n }\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToClass, new ClassId(this.schemaItemType, classKey), e);\n }\n }\n\n /**\n * Sets the base class of a SchemaItem.\n * @param itemKey The SchemaItemKey of the Item.\n * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.\n */\n public async setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<void> {\n try {\n const classItem = await this.getSchemaItem(itemKey, this.itemTypeClass);\n if (!baseClassKey) {\n await (classItem as MutableClass).setBaseClass(undefined);\n return;\n }\n\n if(!await this.schemaEditor.schemaContext.getSchema(baseClassKey.schemaKey)) {\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(baseClassKey.schemaKey));\n }\n\n const baseClassItem = await this.getSchemaItem(baseClassKey, this.itemTypeClass);\n if (classItem.baseClass !== undefined && !await baseClassItem.is(await classItem.baseClass))\n throw new SchemaEditingError(ECEditingStatus.InvalidBaseClass, new ClassId(this.schemaItemType, baseClassKey), undefined, undefined, `Base class ${baseClassKey.fullName} must derive from ${(await classItem.baseClass).fullName}.`);\n\n await (classItem as MutableClass).setBaseClass(new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClassKey, async () => baseClassItem));\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(this.schemaItemType, itemKey), e);\n }\n }\n\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\n const schema = await this.getSchema(classKey.schemaKey);\n\n const ecClass = await schema.getItem(classKey.name);\n if (ecClass === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new ClassId(this.schemaItemType, classKey));\n\n if(!isMutableClass(ecClass))\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new ClassId(this.schemaItemType, classKey));\n\n return ecClass;\n }\n\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\n assert(container.customAttributes !== undefined);\n const map = container.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n}\n\nfunction isMutableClass(schemaItem: SchemaItem): schemaItem is MutableClass {\n return ECClass.isECClass(schemaItem);\n}\n"]}
@@ -103,7 +103,12 @@ class MergingSchemaContext extends ecschema_metadata_1.SchemaContext {
103
103
  async getSchema(schemaKey, matchType) {
104
104
  return this._internalContext.getSchema(schemaKey, matchType);
105
105
  }
106
- async getSchemaItem(schemaItemKey, itemConstructor) {
106
+ async getSchemaItem(schemaNameOrKey, itemNameOrCtor, itemConstructor) {
107
+ let schemaItemKey;
108
+ if (typeof schemaNameOrKey === "string")
109
+ schemaItemKey = new ecschema_metadata_1.SchemaItemKey(itemNameOrCtor, new ecschema_metadata_1.SchemaKey(schemaNameOrKey));
110
+ else
111
+ schemaItemKey = schemaNameOrKey;
107
112
  const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);
108
113
  if (mappedKey !== undefined) {
109
114
  schemaItemKey = mappedKey;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAwH;AACxH,8CAAwD;AACxD,mDAA8D;AAC9D,uEAAqG;AACrG,iEAA8D;AAC9D,+DAA4D;AAE5D,oDAA2E;AAC3E,qDAAkD;AAclD;;;;GAIG;AACH,MAAa,YAAY;IAEN,eAAe,CAAgB;IAEhD;;;OAGG;IACH,YAAY,cAA6B;QACvC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,YAAY,CAAC,YAAoB,EAAE,YAAoB,EAAE,KAAmB;QACvF,OAAO,IAAI,CAAC,KAAK,CA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CAAC,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QACnE,IAAG,SAAS,KAAK,SAAS,EAAE,CAAC;YAC3B,aAAa,GAAG,SAA0B,CAAC;QAC7C,CAAC;QAED,IAAG,eAAe,KAAK,SAAS;YAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","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 { Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"../Editing/Editor\";\nimport { SchemaConflictsError } from \"../Differencing/Errors\";\nimport { getSchemaDifferences, type SchemaDifferenceResult } from \"../Differencing/SchemaDifference\";\nimport { SchemaMergingVisitor } from \"./SchemaMergingVisitor\";\nimport { SchemaMergingWalker } from \"./SchemaMergingWalker\";\nimport { SchemaEdits } from \"./Edits/SchemaEdits\";\nimport { ECEditingStatus, SchemaEditingError } from \"../Editing/Exception\";\nimport { NameMapping } from \"./Edits/NameMapping\";\n\n/**\n * Defines the context of a Schema merging run.\n * @internal\n */\nexport interface SchemaMergeContext {\n readonly targetSchema: Schema;\n readonly targetSchemaKey: SchemaKey;\n readonly sourceSchemaKey: SchemaKey;\n readonly editor: SchemaContextEditor;\n readonly nameMapping: NameMapping;\n}\n\n/**\n * Class to merge two schemas together.\n * @see [[merge]] or [[mergeSchemas]] to merge two schemas together.\n * @beta\n */\nexport class SchemaMerger {\n\n private readonly _editingContext: SchemaContext;\n\n /**\n * Constructs a new instance of the SchemaMerger object.\n * @param editingContext The schema contexts that holds the schema to be edited.\n */\n constructor(editingContext: SchemaContext) {\n this._editingContext = editingContext;\n }\n\n /**\n * Copy the SchemaItems of the source schemas to the target schema.\n * @param targetSchema The schema the SchemaItems gets merged to.\n * @param sourceSchema The schema the SchemaItems gets copied from.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @returns The merged target schema.\n * @alpha\n */\n public async mergeSchemas(targetSchema: Schema, sourceSchema: Schema, edits?: SchemaEdits): Promise<Schema> {\n return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);\n }\n\n /**\n * Merges the schema differences into the target schema context.\n * @param differenceResult The differences that shall be applied to the target schema.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @alpha\n */\n public async merge(differenceResult: SchemaDifferenceResult, edits?: SchemaEdits): Promise<Schema> {\n const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);\n const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);\n\n const nameMapping = new NameMapping();\n const editor = new SchemaContextEditor(new MergingSchemaContext(this._editingContext, nameMapping));\n\n // If schema changes were provided, they'll get applied and a new SchemaDifferenceResult is returned\n // to prevent altering the differenceResult the caller passed in.\n if (edits) {\n await edits.applyTo(differenceResult = { ...differenceResult }, nameMapping);\n }\n\n if (differenceResult.conflicts && differenceResult.conflicts.length > 0) {\n throw new SchemaConflictsError(\n \"Schema's can't be merged if there are unresolved conflicts.\",\n differenceResult.conflicts,\n sourceSchemaKey,\n targetSchemaKey,\n );\n }\n\n const schema = await editor.getSchema(targetSchemaKey).catch((error: Error) => {\n if (error instanceof SchemaEditingError && error.errorNumber === ECEditingStatus.SchemaNotFound) {\n throw new Error(`The target schema '${targetSchemaKey.name}' could not be found in the editing context.`);\n }\n throw error;\n });\n\n if (!schema.customAttributes || !schema.customAttributes.has(\"CoreCustomAttributes.DynamicSchema\")) {\n throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);\n }\n\n const visitor = new SchemaMergingVisitor({\n editor,\n targetSchema: schema,\n targetSchemaKey,\n sourceSchemaKey,\n nameMapping,\n });\n\n const walker = new SchemaMergingWalker(visitor);\n await walker.traverse(differenceResult.differences, \"add\");\n await walker.traverse(differenceResult.differences, \"modify\");\n\n return schema;\n }\n}\n\n/**\n * SchemaContext implementation that overrides certain methods to allow to apply name mappings\n * for certain schema elements during the schema merging process.\n *\n * @internal\n */\nclass MergingSchemaContext extends SchemaContext {\n private _internalContext: SchemaContext;\n private _nameMappings: NameMapping;\n\n public constructor(internalContext: SchemaContext, nameMapping: NameMapping) {\n super();\n this._internalContext = internalContext;\n this._nameMappings = nameMapping;\n }\n\n public override async getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getCachedSchema(schemaKey, matchType);\n }\n\n public override async getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getSchema(schemaKey, matchType);\n }\n\n public override async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\n const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);\n if(mappedKey !== undefined) {\n schemaItemKey = mappedKey as SchemaItemKey;\n }\n\n if(itemConstructor === undefined)\n return this._internalContext.getSchemaItem(schemaItemKey);\n\n return this._internalContext.getSchemaItem(schemaItemKey, itemConstructor);\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAwH;AACxH,8CAAwD;AACxD,mDAA8D;AAC9D,uEAAqG;AACrG,iEAA8D;AAC9D,+DAA4D;AAE5D,oDAA2E;AAC3E,qDAAkD;AAclD;;;;GAIG;AACH,MAAa,YAAY;IAEN,eAAe,CAAgB;IAEhD;;;OAGG;IACH,YAAY,cAA6B;QACvC,IA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,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAEe,KAAK,CAAC,aAAa,CAA8B,eAAuC,EAAE,cAA2B,EAAE,eAAmB;QACxJ,IAAI,aAA4B,CAAC;QACjC,IAAI,OAAO,eAAe,KAAK,QAAQ;YACrC,aAAa,GAAG,IAAI,iCAAa,CAAC,cAAwB,EAAE,IAAI,6BAAS,CAAC,eAAe,CAAC,CAAC,CAAC;;YAE5F,aAAa,GAAG,eAAe,CAAC;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QACnE,IAAG,SAAS,KAAK,SAAS,EAAE,CAAC;YAC3B,aAAa,GAAG,SAA0B,CAAC;QAC7C,CAAC;QAED,IAAG,eAAe,KAAK,SAAS;YAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","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 { Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"../Editing/Editor\";\nimport { SchemaConflictsError } from \"../Differencing/Errors\";\nimport { getSchemaDifferences, type SchemaDifferenceResult } from \"../Differencing/SchemaDifference\";\nimport { SchemaMergingVisitor } from \"./SchemaMergingVisitor\";\nimport { SchemaMergingWalker } from \"./SchemaMergingWalker\";\nimport { SchemaEdits } from \"./Edits/SchemaEdits\";\nimport { ECEditingStatus, SchemaEditingError } from \"../Editing/Exception\";\nimport { NameMapping } from \"./Edits/NameMapping\";\n\n/**\n * Defines the context of a Schema merging run.\n * @internal\n */\nexport interface SchemaMergeContext {\n readonly targetSchema: Schema;\n readonly targetSchemaKey: SchemaKey;\n readonly sourceSchemaKey: SchemaKey;\n readonly editor: SchemaContextEditor;\n readonly nameMapping: NameMapping;\n}\n\n/**\n * Class to merge two schemas together.\n * @see [[merge]] or [[mergeSchemas]] to merge two schemas together.\n * @beta\n */\nexport class SchemaMerger {\n\n private readonly _editingContext: SchemaContext;\n\n /**\n * Constructs a new instance of the SchemaMerger object.\n * @param editingContext The schema contexts that holds the schema to be edited.\n */\n constructor(editingContext: SchemaContext) {\n this._editingContext = editingContext;\n }\n\n /**\n * Copy the SchemaItems of the source schemas to the target schema.\n * @param targetSchema The schema the SchemaItems gets merged to.\n * @param sourceSchema The schema the SchemaItems gets copied from.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @returns The merged target schema.\n * @alpha\n */\n public async mergeSchemas(targetSchema: Schema, sourceSchema: Schema, edits?: SchemaEdits): Promise<Schema> {\n return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);\n }\n\n /**\n * Merges the schema differences into the target schema context.\n * @param differenceResult The differences that shall be applied to the target schema.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @alpha\n */\n public async merge(differenceResult: SchemaDifferenceResult, edits?: SchemaEdits): Promise<Schema> {\n const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);\n const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);\n\n const nameMapping = new NameMapping();\n const editor = new SchemaContextEditor(new MergingSchemaContext(this._editingContext, nameMapping));\n\n // If schema changes were provided, they'll get applied and a new SchemaDifferenceResult is returned\n // to prevent altering the differenceResult the caller passed in.\n if (edits) {\n await edits.applyTo(differenceResult = { ...differenceResult }, nameMapping);\n }\n\n if (differenceResult.conflicts && differenceResult.conflicts.length > 0) {\n throw new SchemaConflictsError(\n \"Schema's can't be merged if there are unresolved conflicts.\",\n differenceResult.conflicts,\n sourceSchemaKey,\n targetSchemaKey,\n );\n }\n\n const schema = await editor.getSchema(targetSchemaKey).catch((error: Error) => {\n if (error instanceof SchemaEditingError && error.errorNumber === ECEditingStatus.SchemaNotFound) {\n throw new Error(`The target schema '${targetSchemaKey.name}' could not be found in the editing context.`);\n }\n throw error;\n });\n\n if (!schema.customAttributes || !schema.customAttributes.has(\"CoreCustomAttributes.DynamicSchema\")) {\n throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);\n }\n\n const visitor = new SchemaMergingVisitor({\n editor,\n targetSchema: schema,\n targetSchemaKey,\n sourceSchemaKey,\n nameMapping,\n });\n\n const walker = new SchemaMergingWalker(visitor);\n await walker.traverse(differenceResult.differences, \"add\");\n await walker.traverse(differenceResult.differences, \"modify\");\n\n return schema;\n }\n}\n\n/**\n * SchemaContext implementation that overrides certain methods to allow to apply name mappings\n * for certain schema elements during the schema merging process.\n *\n * @internal\n */\nclass MergingSchemaContext extends SchemaContext {\n private _internalContext: SchemaContext;\n private _nameMappings: NameMapping;\n\n public constructor(internalContext: SchemaContext, nameMapping: NameMapping) {\n super();\n this._internalContext = internalContext;\n this._nameMappings = nameMapping;\n }\n\n public override async getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getCachedSchema(schemaKey, matchType);\n }\n\n public override async getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getSchema(schemaKey, matchType);\n }\n\n public override async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string | SchemaItemKey, itemNameOrCtor?: string | T, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\n let schemaItemKey: SchemaItemKey;\n if (typeof schemaNameOrKey === \"string\")\n schemaItemKey = new SchemaItemKey(itemNameOrCtor as string, new SchemaKey(schemaNameOrKey));\n else\n schemaItemKey = schemaNameOrKey;\n\n const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);\n if(mappedKey !== undefined) {\n schemaItemKey = mappedKey as SchemaItemKey;\n }\n\n if(itemConstructor === undefined)\n return this._internalContext.getSchemaItem(schemaItemKey);\n\n return this._internalContext.getSchemaItem(schemaItemKey, itemConstructor);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaWalker.d.ts","sourceRoot":"","sources":["../../../src/Validation/SchemaWalker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAW,kBAAkB,EAAqB,MAAM,EAE9D,MAAM,0BAA0B,CAAC;AAElC;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,cAAc,CAA4B;IAIlD,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB;;;OAGG;gBACS,OAAO,EAAE,kBAAkB;IAIvC;;;OAGG;IACU,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAW9C,kBAAkB;YAOlB,aAAa;CAY5B"}
1
+ {"version":3,"file":"SchemaWalker.d.ts","sourceRoot":"","sources":["../../../src/Validation/SchemaWalker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAW,kBAAkB,EAAqB,MAAM,EAE9D,MAAM,0BAA0B,CAAC;AAElC;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,cAAc,CAA4B;IAIlD,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB;;;OAGG;gBACS,OAAO,EAAE,kBAAkB;IAIvC;;;OAGG;IACU,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAW9C,kBAAkB;YAOlB,aAAa;CAU5B"}
@@ -41,10 +41,8 @@ class SchemaWalker {
41
41
  await this.traverseClass(schemaItem);
42
42
  }
43
43
  async traverseClass(ecClass) {
44
- if (ecClass.properties) {
45
- for (const property of ecClass.properties) {
46
- await this._visitorHelper.visitSchemaPart(property);
47
- }
44
+ for (const property of await ecClass.getProperties(true)) {
45
+ await this._visitorHelper.visitSchemaPart(property);
48
46
  }
49
47
  if (ecClass.schemaItemType === ecschema_metadata_1.SchemaItemType.RelationshipClass) {
50
48
  await this._visitorHelper.visitSchemaPart(ecClass.source);
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaWalker.js","sourceRoot":"","sources":["../../../src/Validation/SchemaWalker.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gEAEkC;AAElC;;;;GAIG;AACH,MAAa,YAAY;IACf,cAAc,CAA4B;IAElD,2GAA2G;IAC3G,sEAAsE;IAC9D,OAAO,CAAU;IAEzB;;;OAGG;IACH,YAAY,OAA2B;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,6CAAyB,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,cAAc,CAAC,MAAc;QACxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAElD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YACxC,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,UAAsB;QACrD,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAEtD,IAAI,2BAAO,CAAC,SAAS,CAAC,UAAU,CAAC;YAC/B,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,OAAgB;QAC1C,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC1C,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,cAAc,KAAK,kCAAc,CAAC,iBAAiB,EAAE,CAAC;YAChE,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAE,OAA6B,CAAC,MAAM,CAAC,CAAC;YACjF,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAE,OAA6B,CAAC,MAAM,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;CACF;AAjDD,oCAiDC","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\nimport { ECClass, ISchemaPartVisitor, RelationshipClass, Schema, SchemaItem,\n SchemaItemType, SchemaPartVisitorDelegate,\n} from \"@itwin/ecschema-metadata\";\n\n/**\n * The purpose of this class is to traverse a given schema, allowing clients to hook into\n * the traversal process via Visitors to allow for custom processing of the schema elements.\n * @internal\n */\nexport class SchemaWalker {\n private _visitorHelper: SchemaPartVisitorDelegate;\n\n // This is a cache of the schema we are traversing. The schema also exists within the _context but in order\n // to not have to go back to the context every time we use this cache.\n private _schema?: Schema;\n\n /**\n * Initializes a new SchemaWalker instance.\n * @param visitor An ISchemaWalkerVisitor implementation whose methods will be called during schema traversal.\n */\n constructor(visitor: ISchemaPartVisitor) {\n this._visitorHelper = new SchemaPartVisitorDelegate(visitor);\n }\n\n /**\n * Traverses the given Schema, calling ISchemaWalkerVisitor methods along the way.\n * @param schema The Schema to traverse.\n */\n public async traverseSchema(schema: Schema): Promise<Schema> {\n this._schema = schema;\n\n await this._visitorHelper.visitSchema(schema);\n await this._visitorHelper.visitSchemaPart(schema);\n\n for (const item of this._schema.getItems())\n await this.traverseSchemaItem(item);\n return schema;\n }\n\n private async traverseSchemaItem(schemaItem: SchemaItem): Promise<void> {\n await this._visitorHelper.visitSchemaPart(schemaItem);\n\n if (ECClass.isECClass(schemaItem))\n await this.traverseClass(schemaItem);\n }\n\n private async traverseClass(ecClass: ECClass): Promise<void> {\n if (ecClass.properties) {\n for (const property of ecClass.properties) {\n await this._visitorHelper.visitSchemaPart(property);\n }\n }\n\n if (ecClass.schemaItemType === SchemaItemType.RelationshipClass) {\n await this._visitorHelper.visitSchemaPart((ecClass as RelationshipClass).source);\n await this._visitorHelper.visitSchemaPart((ecClass as RelationshipClass).target);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaWalker.js","sourceRoot":"","sources":["../../../src/Validation/SchemaWalker.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gEAEkC;AAElC;;;;GAIG;AACH,MAAa,YAAY;IACf,cAAc,CAA4B;IAElD,2GAA2G;IAC3G,sEAAsE;IAC9D,OAAO,CAAU;IAEzB;;;OAGG;IACH,YAAY,OAA2B;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,6CAAyB,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,cAAc,CAAC,MAAc;QACxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAElD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YACxC,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,UAAsB;QACrD,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAEtD,IAAI,2BAAO,CAAC,SAAS,CAAC,UAAU,CAAC;YAC/B,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,OAAgB;QAC1C,KAAK,MAAM,QAAQ,IAAI,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,OAAO,CAAC,cAAc,KAAK,kCAAc,CAAC,iBAAiB,EAAE,CAAC;YAChE,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAE,OAA6B,CAAC,MAAM,CAAC,CAAC;YACjF,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAE,OAA6B,CAAC,MAAM,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;CACF;AA/CD,oCA+CC","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\nimport { ECClass, ISchemaPartVisitor, RelationshipClass, Schema, SchemaItem,\n SchemaItemType, SchemaPartVisitorDelegate,\n} from \"@itwin/ecschema-metadata\";\n\n/**\n * The purpose of this class is to traverse a given schema, allowing clients to hook into\n * the traversal process via Visitors to allow for custom processing of the schema elements.\n * @internal\n */\nexport class SchemaWalker {\n private _visitorHelper: SchemaPartVisitorDelegate;\n\n // This is a cache of the schema we are traversing. The schema also exists within the _context but in order\n // to not have to go back to the context every time we use this cache.\n private _schema?: Schema;\n\n /**\n * Initializes a new SchemaWalker instance.\n * @param visitor An ISchemaWalkerVisitor implementation whose methods will be called during schema traversal.\n */\n constructor(visitor: ISchemaPartVisitor) {\n this._visitorHelper = new SchemaPartVisitorDelegate(visitor);\n }\n\n /**\n * Traverses the given Schema, calling ISchemaWalkerVisitor methods along the way.\n * @param schema The Schema to traverse.\n */\n public async traverseSchema(schema: Schema): Promise<Schema> {\n this._schema = schema;\n\n await this._visitorHelper.visitSchema(schema);\n await this._visitorHelper.visitSchemaPart(schema);\n\n for (const item of this._schema.getItems())\n await this.traverseSchemaItem(item);\n return schema;\n }\n\n private async traverseSchemaItem(schemaItem: SchemaItem): Promise<void> {\n await this._visitorHelper.visitSchemaPart(schemaItem);\n\n if (ECClass.isECClass(schemaItem))\n await this.traverseClass(schemaItem);\n }\n\n private async traverseClass(ecClass: ECClass): Promise<void> {\n for (const property of await ecClass.getProperties(true)) {\n await this._visitorHelper.visitSchemaPart(property);\n }\n\n if (ecClass.schemaItemType === SchemaItemType.RelationshipClass) {\n await this._visitorHelper.visitSchemaPart((ecClass as RelationshipClass).source);\n await this._visitorHelper.visitSchemaPart((ecClass as RelationshipClass).target);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-editing",
3
- "version": "5.0.0-dev.89",
3
+ "version": "5.0.0-dev.90",
4
4
  "description": "ECSchema editing and validation API",
5
5
  "license": "MIT",
6
6
  "main": "lib/cjs/ecschema-editing.js",
@@ -41,16 +41,16 @@
41
41
  "rimraf": "^6.0.1",
42
42
  "sinon": "^17.0.2",
43
43
  "typescript": "~5.6.2",
44
- "@itwin/build-tools": "5.0.0-dev.89",
45
- "@itwin/core-common": "5.0.0-dev.89",
46
- "@itwin/core-bentley": "5.0.0-dev.89",
47
- "@itwin/core-quantity": "5.0.0-dev.89",
48
- "@itwin/ecschema-metadata": "5.0.0-dev.89"
44
+ "@itwin/build-tools": "5.0.0-dev.90",
45
+ "@itwin/core-common": "5.0.0-dev.90",
46
+ "@itwin/ecschema-metadata": "5.0.0-dev.90",
47
+ "@itwin/core-bentley": "5.0.0-dev.90",
48
+ "@itwin/core-quantity": "5.0.0-dev.90"
49
49
  },
50
50
  "peerDependencies": {
51
- "@itwin/core-bentley": "5.0.0-dev.89",
52
- "@itwin/core-quantity": "5.0.0-dev.89",
53
- "@itwin/ecschema-metadata": "5.0.0-dev.89"
51
+ "@itwin/core-bentley": "5.0.0-dev.90",
52
+ "@itwin/core-quantity": "5.0.0-dev.90",
53
+ "@itwin/ecschema-metadata": "5.0.0-dev.90"
54
54
  },
55
55
  "nyc": {
56
56
  "extends": "./node_modules/@itwin/build-tools/.nycrc"