@itwin/ecschema-editing 4.6.0-dev.18 → 4.6.0-dev.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/lib/cjs/Differencing/SchemaDifference.d.ts +2 -2
  2. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
  3. package/lib/cjs/Differencing/SchemaDifference.js +1 -1
  4. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  5. package/lib/cjs/Editing/CustomAttributes.d.ts +1 -1
  6. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  7. package/lib/cjs/Editing/CustomAttributes.js +2 -2
  8. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  9. package/lib/cjs/Editing/ECClasses.d.ts +5 -7
  10. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  11. package/lib/cjs/Editing/ECClasses.js +7 -10
  12. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  13. package/lib/cjs/Editing/Entities.d.ts +6 -1
  14. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  15. package/lib/cjs/Editing/Entities.js +7 -2
  16. package/lib/cjs/Editing/Entities.js.map +1 -1
  17. package/lib/cjs/Editing/Mixins.d.ts +6 -1
  18. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  19. package/lib/cjs/Editing/Mixins.js +7 -2
  20. package/lib/cjs/Editing/Mixins.js.map +1 -1
  21. package/lib/cjs/Editing/Properties.d.ts +9 -7
  22. package/lib/cjs/Editing/Properties.d.ts.map +1 -1
  23. package/lib/cjs/Editing/Properties.js +17 -13
  24. package/lib/cjs/Editing/Properties.js.map +1 -1
  25. package/lib/cjs/Editing/RelationshipClasses.d.ts +6 -1
  26. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  27. package/lib/cjs/Editing/RelationshipClasses.js +7 -2
  28. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  29. package/lib/cjs/Editing/Structs.d.ts +1 -1
  30. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  31. package/lib/cjs/Editing/Structs.js +2 -2
  32. package/lib/cjs/Editing/Structs.js.map +1 -1
  33. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
  34. package/lib/cjs/Merging/PropertyMerger.js +48 -23
  35. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  36. package/lib/cjs/ecschema-editing.d.ts +2 -1
  37. package/lib/cjs/ecschema-editing.d.ts.map +1 -1
  38. package/lib/cjs/ecschema-editing.js +3 -3
  39. package/lib/cjs/ecschema-editing.js.map +1 -1
  40. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"Entities.js","sourceRoot":"","sources":["../../../src/Editing/Entities.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAElC,2CAAwC;AAGxC;;;GAGG;AACH,MAAa,QAAS,SAAQ,qBAAS;IACrC,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAyB,EAAE,YAA2B,EAAE,YAAqB,EAAE,MAAgB;QAC5J,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QACrF,IAAI,CAAC,SAAS;YACZ,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,0DAA0D,YAAY,CAAC,QAAQ,sBAAsB,CAAC,CAAC;QAE1I,IAAI,SAAS,EAAE,cAAc,KAAK,kCAAc,CAAC,WAAW;YAC1D,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,0DAA0D,YAAY,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAE7I,IAAI,CAAC,CAAC,MAAO,SAAyB,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE;YAChE,M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CAAC,WAAW;YACtD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,QAAQ,CAAC,QAAQ,6BAA6B,EAAE,CAAC;QAE7I,MAAM,kBAAkB,GAAI,MAAM,MAAM,CAAC,wBAAwB,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;QACrJ,MAAM,kBAAkB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAEnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC;IACnE,CAAC;CACF;AA/JD,4BA+JC","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 DelayedPromiseWithProps, ECClassModifier, ECObjectsError, ECObjectsStatus, EntityClass, EntityClassProps,\r\n Mixin, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaItemType, SchemaKey, StrengthDirection,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableEntityClass } from \"./Mutable/MutableEntityClass\";\r\n\r\n/**\r\n * @alpha\r\n * A class extending ECClasses allowing you to create schema items of type EntityClass.\r\n */\r\nexport class Entities extends ECClasses {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n public async createElement(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemEditResults> {\r\n const baseClass = await this._schemaEditor.schemaContext.getSchemaItem(baseClassKey);\r\n if (!baseClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} could not be found.`);\r\n\r\n if (baseClass?.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an EntityClass.`);\r\n\r\n if (!(await (baseClass as EntityClass).is(\"Element\", \"BisCore\"))) {\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an Element.`);\r\n }\r\n\r\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\r\n }\r\n\r\n public async createElementUniqueAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemEditResults> {\r\n const baseClass = await this._schemaEditor.schemaContext.getSchemaItem(baseClassKey);\r\n if (!baseClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} could not be found.`);\r\n\r\n if (baseClass?.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an EntityClass.`);\r\n\r\n if (!(await (baseClass as EntityClass).is(\"ElementUniqueAspect\", \"BisCore\"))) {\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an ElementUniqueAspect.`);\r\n }\r\n\r\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\r\n }\r\n\r\n public async createElementMultiAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemEditResults> {\r\n const baseClass = await this._schemaEditor.schemaContext.getSchemaItem(baseClassKey);\r\n if (!baseClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} could be found.`);\r\n\r\n if (baseClass?.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an EntityClass.`);\r\n\r\n if (!(await (baseClass as EntityClass).is(\"ElementMultiAspect\", \"BisCore\"))) {\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an ElementMultiAspect.`);\r\n }\r\n\r\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, displayLabel?: string, baseClassKey?: SchemaItemKey, mixins?: Mixin[]): 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 const newClass = (await schema.createEntityClass(name, modifier)) as MutableEntityClass;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n // Add a deserializing method.\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<EntityClass>(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.EntityClass)\r\n return { errorMessage: `${baseClassItem.fullName} is not of type Entity Class.` };\r\n\r\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(baseClassKey, async () => baseClassItem);\r\n }\r\n\r\n if (mixins !== undefined)\r\n mixins.forEach((m) => newClass.addMixin(m));\r\n\r\n if (displayLabel)\r\n newClass.setDisplayLabel(displayLabel);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n /**\r\n * Creates an EntityClass through an EntityClassProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param entityProps a json object that will be used to populate the new EntityClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, entityProps: EntityClassProps): 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 (entityProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newClass = (await schema.createEntityClass(entityProps.name)) as MutableEntityClass;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${entityProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newClass.fromJSON(entityProps);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n public async addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<SchemaItemEditResults> {\r\n const entity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableEntityClass>(entityKey));\r\n if (entity === undefined) {\r\n return { errorMessage: `Entity Class ${entityKey.fullName} not found in schema context.` };\r\n }\r\n if (entity.schemaItemType !== SchemaItemType.EntityClass) {\r\n return { errorMessage: `Expected ${entityKey.fullName} to be of type Entity Class.` };\r\n }\r\n\r\n const mixin = (await this._schemaEditor.schemaContext.getSchemaItem<Mixin>(mixinKey));\r\n if (mixin === undefined) {\r\n return { errorMessage: `Mixin Class ${mixinKey.fullName} not found in schema context.` };\r\n }\r\n if (mixin.schemaItemType !== SchemaItemType.Mixin) {\r\n return { errorMessage: `Expected ${mixinKey.fullName} to be of type Mixin.`};\r\n }\r\n\r\n entity.addMixin(mixin);\r\n return { itemKey: entityKey };\r\n }\r\n\r\n public async createNavigationProperty(entityKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults> {\r\n const entity = await this._schemaEditor.schemaContext.getSchemaItem<MutableEntityClass>(entityKey);\r\n\r\n if (entity === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${entityKey.fullName} not found in schema context.`);\r\n\r\n if (entity.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${entityKey.fullName} to be of type Entity Class.`);\r\n\r\n await entity.createNavigationProperty(name, relationship, direction);\r\n return { itemKey: entityKey, 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 Entity 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(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<PropertyEditResults> {\r\n const entity = await this._schemaEditor.schemaContext.getSchemaItem<MutableEntityClass>(classKey);\r\n if (entity === undefined)\r\n return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Entity Class ${classKey.fullName} not found in schema context.`};\r\n\r\n if (entity.schemaItemType !== SchemaItemType.EntityClass)\r\n return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Expected ${classKey.fullName} to be of type EntityClass.` };\r\n\r\n const navigationProperty = await entity.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\r\n await navigationProperty.fromJSON(navigationProps);\r\n\r\n return { itemKey: classKey, propertyName: navigationProps.name };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Entities.js","sourceRoot":"","sources":["../../../src/Editing/Entities.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAElC,2CAAwC;AAExC,6CAAoD;AAEpD;;;GAGG;AACH,MAAa,QAAS,SAAQ,qBAAS;IACrC,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAGlD;;WAEG;QACa,yBAAoB,GAAG,IAAI,iCAAoB,CAAC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c,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,SAAS,CAAC,QAAQ,8BAA8B,CAAC,CAAC;QAEhI,MAAM,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QACrE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,iCAAiC,CAAC,QAAuB,EAAE,eAAwC;QAC9G,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAqB,QAAQ,CAAC,CAAC;QAClG,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,gBAAgB,QAAQ,CAAC,QAAQ,+BAA+B,EAAC,CAAC;QAElJ,IAAI,MAAM,CAAC,cAAc,KAAK,kCAAc,CAAC,WAAW;YACtD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,QAAQ,CAAC,QAAQ,6BAA6B,EAAE,CAAC;QAE7I,MAAM,kBAAkB,GAAI,MAAM,MAAM,CAAC,wBAAwB,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;QACrJ,MAAM,kBAAkB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAEnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC;IACnE,CAAC;CACF;AApKD,4BAoKC","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 DelayedPromiseWithProps, ECClassModifier, ECObjectsError, ECObjectsStatus, EntityClass, EntityClassProps,\r\n Mixin, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaItemType, SchemaKey, StrengthDirection,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableEntityClass } from \"./Mutable/MutableEntityClass\";\r\nimport { NavigationProperties } from \"./Properties\";\r\n\r\n/**\r\n * @alpha\r\n * A class extending ECClasses allowing you to create schema items of type EntityClass.\r\n */\r\nexport class Entities extends ECClasses {\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.EntityClass, schemaEditor);\r\n }\r\n\r\n /**\r\n * Allows access for editing of NavigationProperty attributes.\r\n */\r\n public readonly navigationProperties = new NavigationProperties(this.schemaItemType, this._schemaEditor);\r\n\r\n public async createElement(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemEditResults> {\r\n const baseClass = await this._schemaEditor.schemaContext.getSchemaItem(baseClassKey);\r\n if (!baseClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} could not be found.`);\r\n\r\n if (baseClass?.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an EntityClass.`);\r\n\r\n if (!(await (baseClass as EntityClass).is(\"Element\", \"BisCore\"))) {\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an Element.`);\r\n }\r\n\r\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\r\n }\r\n\r\n public async createElementUniqueAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemEditResults> {\r\n const baseClass = await this._schemaEditor.schemaContext.getSchemaItem(baseClassKey);\r\n if (!baseClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} could not be found.`);\r\n\r\n if (baseClass?.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an EntityClass.`);\r\n\r\n if (!(await (baseClass as EntityClass).is(\"ElementUniqueAspect\", \"BisCore\"))) {\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an ElementUniqueAspect.`);\r\n }\r\n\r\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\r\n }\r\n\r\n public async createElementMultiAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemEditResults> {\r\n const baseClass = await this._schemaEditor.schemaContext.getSchemaItem(baseClassKey);\r\n if (!baseClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} could be found.`);\r\n\r\n if (baseClass?.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an EntityClass.`);\r\n\r\n if (!(await (baseClass as EntityClass).is(\"ElementMultiAspect\", \"BisCore\"))) {\r\n throw new Error(`The class ${name} could not be created because the specified base class ${baseClassKey.fullName} is not an ElementMultiAspect.`);\r\n }\r\n\r\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, displayLabel?: string, baseClassKey?: SchemaItemKey, mixins?: Mixin[]): 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 const newClass = (await schema.createEntityClass(name, modifier)) as MutableEntityClass;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n // Add a deserializing method.\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<EntityClass>(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.EntityClass)\r\n return { errorMessage: `${baseClassItem.fullName} is not of type Entity Class.` };\r\n\r\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(baseClassKey, async () => baseClassItem);\r\n }\r\n\r\n if (mixins !== undefined)\r\n mixins.forEach((m) => newClass.addMixin(m));\r\n\r\n if (displayLabel)\r\n newClass.setDisplayLabel(displayLabel);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n /**\r\n * Creates an EntityClass through an EntityClassProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param entityProps a json object that will be used to populate the new EntityClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, entityProps: EntityClassProps): 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 (entityProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newClass = (await schema.createEntityClass(entityProps.name)) as MutableEntityClass;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${entityProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newClass.fromJSON(entityProps);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n public async addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<SchemaItemEditResults> {\r\n const entity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableEntityClass>(entityKey));\r\n if (entity === undefined) {\r\n return { errorMessage: `Entity Class ${entityKey.fullName} not found in schema context.` };\r\n }\r\n if (entity.schemaItemType !== SchemaItemType.EntityClass) {\r\n return { errorMessage: `Expected ${entityKey.fullName} to be of type Entity Class.` };\r\n }\r\n\r\n const mixin = (await this._schemaEditor.schemaContext.getSchemaItem<Mixin>(mixinKey));\r\n if (mixin === undefined) {\r\n return { errorMessage: `Mixin Class ${mixinKey.fullName} not found in schema context.` };\r\n }\r\n if (mixin.schemaItemType !== SchemaItemType.Mixin) {\r\n return { errorMessage: `Expected ${mixinKey.fullName} to be of type Mixin.`};\r\n }\r\n\r\n entity.addMixin(mixin);\r\n return { itemKey: entityKey };\r\n }\r\n\r\n public async createNavigationProperty(entityKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults> {\r\n const entity = await this._schemaEditor.schemaContext.getSchemaItem<MutableEntityClass>(entityKey);\r\n\r\n if (entity === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${entityKey.fullName} not found in schema context.`);\r\n\r\n if (entity.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${entityKey.fullName} to be of type Entity Class.`);\r\n\r\n await entity.createNavigationProperty(name, relationship, direction);\r\n return { itemKey: entityKey, 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 Entity 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(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<PropertyEditResults> {\r\n const entity = await this._schemaEditor.schemaContext.getSchemaItem<MutableEntityClass>(classKey);\r\n if (entity === undefined)\r\n return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Entity Class ${classKey.fullName} not found in schema context.`};\r\n\r\n if (entity.schemaItemType !== SchemaItemType.EntityClass)\r\n return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Expected ${classKey.fullName} to be of type EntityClass.` };\r\n\r\n const navigationProperty = await entity.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\r\n await navigationProperty.fromJSON(navigationProps);\r\n\r\n return { itemKey: classKey, propertyName: navigationProps.name };\r\n }\r\n}\r\n"]}
@@ -4,12 +4,17 @@
4
4
  import { MixinProps, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
5
5
  import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
6
  import { ECClasses } from "./ECClasses";
7
+ import { NavigationProperties } from "./Properties";
7
8
  /**
8
9
  * @alpha
9
10
  * A class extending ECClasses allowing you to create schema items of type Mixin.
10
11
  */
11
12
  export declare class Mixins extends ECClasses {
12
- constructor(_schemaEditor: SchemaContextEditor);
13
+ constructor(schemaEditor: SchemaContextEditor);
14
+ /**
15
+ * Allows access for editing of NavigationProperty attributes.
16
+ */
17
+ readonly navigationProperties: NavigationProperties;
13
18
  create(schemaKey: SchemaKey, name: string, appliesTo: SchemaItemKey, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
14
19
  /**
15
20
  * Creates a MixinClass through a MixinProps.
@@ -1 +1 @@
1
- {"version":3,"file":"Mixins.d.ts","sourceRoot":"","sources":["../../../src/Editing/Mixins.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACyE,UAAU,EAAE,uBAAuB,EAAE,iBAAiB,EACpI,aAAa,EAAkB,SAAS,EAAE,iBAAiB,EAC5D,MAAM,0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a,CAAC;AAGxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,qBAAa,MAAO,SAAQ,SAAS;gBAChB,YAAY,EAAE,mBAAmB;IAIpD;;OAEG;IACH,SAAgB,oBAAoB,uBAAqE;IAE5F,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgCnK;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgB7F,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB1E,wBAAwB,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAa3L;;;;OAIG;IACU,iCAAiC,CAAC,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAahJ"}
@@ -10,13 +10,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.Mixins = void 0;
11
11
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
12
  const ECClasses_1 = require("./ECClasses");
13
+ const Properties_1 = require("./Properties");
13
14
  /**
14
15
  * @alpha
15
16
  * A class extending ECClasses allowing you to create schema items of type Mixin.
16
17
  */
17
18
  class Mixins extends ECClasses_1.ECClasses {
18
- constructor(_schemaEditor) {
19
- super(_schemaEditor);
19
+ constructor(schemaEditor) {
20
+ super(ecschema_metadata_1.SchemaItemType.Mixin, schemaEditor);
21
+ /**
22
+ * Allows access for editing of NavigationProperty attributes.
23
+ */
24
+ this.navigationProperties = new Properties_1.NavigationProperties(this.schemaItemType, this._schemaEditor);
20
25
  }
21
26
  async create(schemaKey, name, appliesTo, displayLabel, baseClass) {
22
27
  const schema = await this._schemaEditor.getSchema(schemaKey);
@@ -1 +1 @@
1
- {"version":3,"file":"Mixins.js","sourceRoot":"","sources":["../../../src/Editing/Mixins.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAElC,2CAAwC;AAIxC;;;GAGG;AACH,MAAa,MAAO,SAAQ,qBAAS;IACnC,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,SAAwB,EAAE,YAAqB,EAAE,SAAyB;QAChI,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,GAAI,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAkB,CAAC;QACzE,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnG,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,UAAU,CAAQ,SAAS,CAAC,CAAC;YAChE,IAAI,aAAa,KAAK,SAAS;gBAC7B,OAAO,EAAE,YAAY,EAAE,+BAA+B,SAAS,CAAC,QAAQ,cAAc,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC;YAE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AC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;QACpJ,MAAM,kBAAkB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAEnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC;IACnE,CAAC;CACF;AA5GD,wBA4GC","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 DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, EntityClass, Mixin, MixinProps, NavigationPropertyProps, RelationshipClass,\r\n SchemaItemKey, SchemaItemType, SchemaKey, StrengthDirection,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableMixin } from \"./Mutable/MutableMixin\";\r\nimport { MutableEntityClass } from \"./Mutable/MutableEntityClass\";\r\n\r\n/**\r\n * @alpha\r\n * A class extending ECClasses allowing you to create schema items of type Mixin.\r\n */\r\nexport class Mixins extends ECClasses {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, appliesTo: SchemaItemKey, displayLabel?: string, baseClass?: 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 const newClass = ((await schema.createMixinClass(name)) as MutableMixin);\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n if (baseClass !== undefined) {\r\n const baseClassItem = await schema.lookupItem<Mixin>(baseClass);\r\n if (baseClassItem === undefined)\r\n return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };\r\n\r\n if (baseClassItem.schemaItemType !== SchemaItemType.Mixin)\r\n return { errorMessage: `${baseClassItem.fullName} is not of type Mixin.` };\r\n\r\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, Mixin>(baseClass, async () => baseClassItem);\r\n }\r\n\r\n const newAppliesTo = (await this._schemaEditor.schemaContext.getSchemaItem<EntityClass>(appliesTo));\r\n if (newAppliesTo === undefined || newAppliesTo.schemaItemType !== SchemaItemType.EntityClass)\r\n return { errorMessage: `Failed to locate the appliedTo entity class ${appliesTo.name}.` };\r\n\r\n newClass.setAppliesTo(new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(newAppliesTo.key, async () => newAppliesTo));\r\n\r\n if (displayLabel)\r\n newClass.setDisplayLabel(displayLabel);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n /**\r\n * Creates a MixinClass through a MixinProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, mixinProps: MixinProps): 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 (mixinProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newClass = (await schema.createMixinClass(mixinProps.name)) as MutableMixin;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${mixinProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newClass.fromJSON(mixinProps);\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n public async addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void> {\r\n const entity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableEntityClass>(entityKey));\r\n const mixin = (await this._schemaEditor.schemaContext.getSchemaItem<Mixin>(mixinKey));\r\n\r\n if (entity === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${entityKey.fullName} not found in schema context.`);\r\n\r\n if (mixin === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Mixin Class ${mixinKey.fullName} not found in schema context.`);\r\n\r\n if (entity.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${entityKey.fullName} to be of type Entity Class.`);\r\n\r\n if (mixin.schemaItemType !== SchemaItemType.Mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${mixinKey.fullName} to be of type Mixin.`);\r\n\r\n entity.addMixin(mixin);\r\n }\r\n\r\n public async createNavigationProperty(mixinKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults> {\r\n const mixin = (await this._schemaEditor.schemaContext.getSchemaItem<MutableMixin>(mixinKey));\r\n\r\n if (mixin === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Mixin Class ${mixinKey.fullName} not found in schema context.`);\r\n\r\n if (mixin.schemaItemType !== SchemaItemType.Mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${mixinKey.fullName} to be of type Mixin.`);\r\n\r\n await mixin.createNavigationProperty(name, relationship, direction);\r\n return { itemKey: mixinKey, 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 Mixin 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(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<PropertyEditResults> {\r\n const mixin = await this._schemaEditor.schemaContext.getSchemaItem<MutableMixin>(classKey);\r\n if (mixin === undefined)\r\n return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Mixin ${classKey.fullName} not found in schema context.`};\r\n\r\n if (mixin.schemaItemType !== SchemaItemType.Mixin)\r\n return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Expected ${classKey.fullName} to be of type Mixin.`};\r\n\r\n const navigationProperty = await mixin.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\r\n await navigationProperty.fromJSON(navigationProps);\r\n\r\n return { itemKey: classKey, propertyName: navigationProps.name };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Mixins.js","sourceRoot":"","sources":["../../../src/Editing/Mixins.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAElC,2CAAwC;AAGxC,6CAAoD;AAEpD;;;GAGG;AACH,MAAa,MAAO,SAAQ,qBAAS;IACnC,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAG5C;;WAEG;QACa,yBAAoB,GAAG,IAAI,iCAAoB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IALzG,CAAC;IAOM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,SAAwB,EAAE,YAAqB,EAAE,SAAyB;QAChI,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,GAAI,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAkB,CAAC;QACzE,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,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,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,QAAQ,CAAC,QAAQ,+BAA+B,EAAC,CAAC;QAE3I,IAAI,KAAK,CAAC,cAAc,KAAK,kCAAc,CAAC,KAAK;YAC/C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,QAAQ,CAAC,QAAQ,uBAAuB,EAAC,CAAC;QAEtI,MAAM,kBAAkB,GAAI,MAAM,KAAK,CAAC,wBAAwB,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;QACpJ,MAAM,kBAAkB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAEnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC;IACnE,CAAC;CACF;AAjHD,wBAiHC","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 DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, EntityClass, Mixin, MixinProps, NavigationPropertyProps, RelationshipClass,\r\n SchemaItemKey, SchemaItemType, SchemaKey, StrengthDirection,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableMixin } from \"./Mutable/MutableMixin\";\r\nimport { MutableEntityClass } from \"./Mutable/MutableEntityClass\";\r\nimport { NavigationProperties } from \"./Properties\";\r\n\r\n/**\r\n * @alpha\r\n * A class extending ECClasses allowing you to create schema items of type Mixin.\r\n */\r\nexport class Mixins extends ECClasses {\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.Mixin, schemaEditor);\r\n }\r\n\r\n /**\r\n * Allows access for editing of NavigationProperty attributes.\r\n */\r\n public readonly navigationProperties = new NavigationProperties(this.schemaItemType, this._schemaEditor);\r\n\r\n public async create(schemaKey: SchemaKey, name: string, appliesTo: SchemaItemKey, displayLabel?: string, baseClass?: 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 const newClass = ((await schema.createMixinClass(name)) as MutableMixin);\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n if (baseClass !== undefined) {\r\n const baseClassItem = await schema.lookupItem<Mixin>(baseClass);\r\n if (baseClassItem === undefined)\r\n return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };\r\n\r\n if (baseClassItem.schemaItemType !== SchemaItemType.Mixin)\r\n return { errorMessage: `${baseClassItem.fullName} is not of type Mixin.` };\r\n\r\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, Mixin>(baseClass, async () => baseClassItem);\r\n }\r\n\r\n const newAppliesTo = (await this._schemaEditor.schemaContext.getSchemaItem<EntityClass>(appliesTo));\r\n if (newAppliesTo === undefined || newAppliesTo.schemaItemType !== SchemaItemType.EntityClass)\r\n return { errorMessage: `Failed to locate the appliedTo entity class ${appliesTo.name}.` };\r\n\r\n newClass.setAppliesTo(new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(newAppliesTo.key, async () => newAppliesTo));\r\n\r\n if (displayLabel)\r\n newClass.setDisplayLabel(displayLabel);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n /**\r\n * Creates a MixinClass through a MixinProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, mixinProps: MixinProps): 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 (mixinProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newClass = (await schema.createMixinClass(mixinProps.name)) as MutableMixin;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${mixinProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newClass.fromJSON(mixinProps);\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n public async addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void> {\r\n const entity = (await this._schemaEditor.schemaContext.getSchemaItem<MutableEntityClass>(entityKey));\r\n const mixin = (await this._schemaEditor.schemaContext.getSchemaItem<Mixin>(mixinKey));\r\n\r\n if (entity === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Entity Class ${entityKey.fullName} not found in schema context.`);\r\n\r\n if (mixin === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Mixin Class ${mixinKey.fullName} not found in schema context.`);\r\n\r\n if (entity.schemaItemType !== SchemaItemType.EntityClass)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${entityKey.fullName} to be of type Entity Class.`);\r\n\r\n if (mixin.schemaItemType !== SchemaItemType.Mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${mixinKey.fullName} to be of type Mixin.`);\r\n\r\n entity.addMixin(mixin);\r\n }\r\n\r\n public async createNavigationProperty(mixinKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults> {\r\n const mixin = (await this._schemaEditor.schemaContext.getSchemaItem<MutableMixin>(mixinKey));\r\n\r\n if (mixin === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Mixin Class ${mixinKey.fullName} not found in schema context.`);\r\n\r\n if (mixin.schemaItemType !== SchemaItemType.Mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${mixinKey.fullName} to be of type Mixin.`);\r\n\r\n await mixin.createNavigationProperty(name, relationship, direction);\r\n return { itemKey: mixinKey, 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 Mixin 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(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<PropertyEditResults> {\r\n const mixin = await this._schemaEditor.schemaContext.getSchemaItem<MutableMixin>(classKey);\r\n if (mixin === undefined)\r\n return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Mixin ${classKey.fullName} not found in schema context.`};\r\n\r\n if (mixin.schemaItemType !== SchemaItemType.Mixin)\r\n return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Expected ${classKey.fullName} to be of type Mixin.`};\r\n\r\n const navigationProperty = await mixin.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\r\n await navigationProperty.fromJSON(navigationProps);\r\n\r\n return { itemKey: classKey, propertyName: navigationProps.name };\r\n }\r\n}\r\n"]}
@@ -5,14 +5,16 @@ import { MutableProperty } from "./Mutable/MutableProperty";
5
5
  import { MutablePrimitiveOrEnumPropertyBase } from "./Mutable/MutablePrimitiveOrEnumProperty";
6
6
  import { MutableStructProperty } from "./Mutable/MutableStructProperty";
7
7
  import { MutableNavigationProperty } from "./Mutable/MutableNavigationProperty";
8
+ import { ECClassSchemaItems } from "./ECClasses";
8
9
  type MutablePropertyType = MutableProperty | MutableArrayProperty | MutablePrimitiveOrEnumPropertyBase | MutableNavigationProperty | MutableStructProperty;
9
10
  /**
10
11
  * @alpha
11
12
  * A class allowing editing of attributes of the base Property class.
12
13
  */
13
14
  export declare class Properties {
15
+ protected ecClassType: ECClassSchemaItems;
14
16
  protected _schemaEditor: SchemaContextEditor;
15
- constructor(_schemaEditor: SchemaContextEditor);
17
+ constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor);
16
18
  setName(classKey: SchemaItemKey, propertyName: string, newPropertyName: string): Promise<void>;
17
19
  /**
18
20
  * Sets the property description.
@@ -79,7 +81,7 @@ export declare class Properties {
79
81
  * EnumerationArrayProperty and StructArrayProperty.
80
82
  */
81
83
  export declare class ArrayProperties extends Properties {
82
- constructor(_schemaEditor: SchemaContextEditor);
84
+ constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor);
83
85
  /**
84
86
  * Sets the array property minOccurs attribute.
85
87
  * @param classKey The SchemaItemKey of the class.
@@ -106,7 +108,7 @@ export declare class ArrayProperties extends Properties {
106
108
  * A class extending Properties allowing editing of attributes of PrimitiveProperty and EnumerationProperty.
107
109
  */
108
110
  declare class PrimitiveOrEnumProperties extends Properties {
109
- constructor(_schemaEditor: SchemaContextEditor);
111
+ constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor);
110
112
  /**
111
113
  * Sets the extendTypeName attribute value.
112
114
  * @param classKey The SchemaItemKey of the class.
@@ -148,7 +150,7 @@ declare class PrimitiveOrEnumProperties extends Properties {
148
150
  * A class extending Properties allowing editing of PrimitiveProperty attributes.
149
151
  */
150
152
  export declare class PrimitiveProperties extends PrimitiveOrEnumProperties {
151
- constructor(_schemaEditor: SchemaContextEditor);
153
+ constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor);
152
154
  /**
153
155
  * Override to validate that the found property is a PrimitiveProperty.
154
156
  * @param classKey The SchemaItemKey of the class.
@@ -161,7 +163,7 @@ export declare class PrimitiveProperties extends PrimitiveOrEnumProperties {
161
163
  * A class extending Properties allowing editing of EnumerationProperty attributes.
162
164
  */
163
165
  export declare class EnumerationProperties extends PrimitiveOrEnumProperties {
164
- constructor(_schemaEditor: SchemaContextEditor);
166
+ constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor);
165
167
  /**
166
168
  * Override to validate that the found property is a EnumerationProperty.
167
169
  * @param classKey The SchemaItemKey of the class.
@@ -174,7 +176,7 @@ export declare class EnumerationProperties extends PrimitiveOrEnumProperties {
174
176
  * A class extending Properties allowing editing of NavigationProperties attributes.
175
177
  */
176
178
  export declare class NavigationProperties extends Properties {
177
- constructor(_schemaEditor: SchemaContextEditor);
179
+ constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor);
178
180
  /**
179
181
  * Override to validate that the found property is a NavigationProperty.
180
182
  * @param classKey The SchemaItemKey of the class.
@@ -187,7 +189,7 @@ export declare class NavigationProperties extends Properties {
187
189
  * A class extending Properties allowing editing of StructProperty attributes.
188
190
  */
189
191
  export declare class StructProperties extends Properties {
190
- constructor(_schemaEditor: SchemaContextEditor);
192
+ constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor);
191
193
  /**
192
194
  * Override to validate that the found property is a StructProperty.
193
195
  * @param classKey The SchemaItemKey of the class.
@@ -1 +1 @@
1
- {"version":3,"file":"Properties.d.ts","sourceRoot":"","sources":["../../../src/Editing/Properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAEJ,aAAa,EAAkB,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kCAAkC,EAAE,MAAM,0CAA0C,CAAC;AAE9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,KAAK,mBAAmB,GAAG,eAAe,GAAG,oBAAoB,GAAG,kCAAk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;GAGG;AACH,qBAAa,oBAAqB,SAAQ,UAAU;gBAC/B,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAE,mBAAmB;IAItF;;;;OAIG;cACsB,WAAW,CAAC,CAAC,SAAS,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;CAQ/H;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;gBAC3B,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAE,mBAAmB;IAItF;;;;OAIG;cACsB,WAAW,CAAC,CAAC,SAAS,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;CAQ/H"}
@@ -8,7 +8,8 @@ const Rules = require("../Validation/ECRules");
8
8
  * A class allowing editing of attributes of the base Property class.
9
9
  */
10
10
  class Properties {
11
- constructor(_schemaEditor) {
11
+ constructor(ecClassType, _schemaEditor) {
12
+ this.ecClassType = ecClassType;
12
13
  this._schemaEditor = _schemaEditor;
13
14
  }
14
15
  async setName(classKey, propertyName, newPropertyName) {
@@ -115,6 +116,9 @@ class Properties {
115
116
  */
116
117
  async getProperty(classKey, propertyName) {
117
118
  const mutableClass = await this.getClass(classKey);
119
+ if (mutableClass.schemaItemType !== this.ecClassType) {
120
+ throw new Error(`The class ${classKey.fullName} is not an ${ecschema_metadata_1.SchemaItemType[this.ecClassType]}.`);
121
+ }
118
122
  const property = await mutableClass.getProperty(propertyName);
119
123
  if (property === undefined) {
120
124
  // TODO: Update error
@@ -153,8 +157,8 @@ exports.Properties = Properties;
153
157
  * EnumerationArrayProperty and StructArrayProperty.
154
158
  */
155
159
  class ArrayProperties extends Properties {
156
- constructor(_schemaEditor) {
157
- super(_schemaEditor);
160
+ constructor(ecClassType, _schemaEditor) {
161
+ super(ecClassType, _schemaEditor);
158
162
  }
159
163
  /**
160
164
  * Sets the array property minOccurs attribute.
@@ -196,8 +200,8 @@ exports.ArrayProperties = ArrayProperties;
196
200
  * A class extending Properties allowing editing of attributes of PrimitiveProperty and EnumerationProperty.
197
201
  */
198
202
  class PrimitiveOrEnumProperties extends Properties {
199
- constructor(_schemaEditor) {
200
- super(_schemaEditor);
203
+ constructor(ecClassType, _schemaEditor) {
204
+ super(ecClassType, _schemaEditor);
201
205
  }
202
206
  /**
203
207
  * Sets the extendTypeName attribute value.
@@ -255,8 +259,8 @@ class PrimitiveOrEnumProperties extends Properties {
255
259
  * A class extending Properties allowing editing of PrimitiveProperty attributes.
256
260
  */
257
261
  class PrimitiveProperties extends PrimitiveOrEnumProperties {
258
- constructor(_schemaEditor) {
259
- super(_schemaEditor);
262
+ constructor(ecClassType, _schemaEditor) {
263
+ super(ecClassType, _schemaEditor);
260
264
  }
261
265
  /**
262
266
  * Override to validate that the found property is a PrimitiveProperty.
@@ -278,8 +282,8 @@ exports.PrimitiveProperties = PrimitiveProperties;
278
282
  * A class extending Properties allowing editing of EnumerationProperty attributes.
279
283
  */
280
284
  class EnumerationProperties extends PrimitiveOrEnumProperties {
281
- constructor(_schemaEditor) {
282
- super(_schemaEditor);
285
+ constructor(ecClassType, _schemaEditor) {
286
+ super(ecClassType, _schemaEditor);
283
287
  }
284
288
  /**
285
289
  * Override to validate that the found property is a EnumerationProperty.
@@ -301,8 +305,8 @@ exports.EnumerationProperties = EnumerationProperties;
301
305
  * A class extending Properties allowing editing of NavigationProperties attributes.
302
306
  */
303
307
  class NavigationProperties extends Properties {
304
- constructor(_schemaEditor) {
305
- super(_schemaEditor);
308
+ constructor(ecClassType, _schemaEditor) {
309
+ super(ecClassType, _schemaEditor);
306
310
  }
307
311
  /**
308
312
  * Override to validate that the found property is a NavigationProperty.
@@ -324,8 +328,8 @@ exports.NavigationProperties = NavigationProperties;
324
328
  * A class extending Properties allowing editing of StructProperty attributes.
325
329
  */
326
330
  class StructProperties extends Properties {
327
- constructor(_schemaEditor) {
328
- super(_schemaEditor);
331
+ constructor(ecClassType, _schemaEditor) {
332
+ super(ecClassType, _schemaEditor);
329
333
  }
330
334
  /**
331
335
  * Override to validate that the found property is a StructProperty.
@@ -1 +1 @@
1
- {"version":3,"file":"Properties.js","sourceRoot":"","sources":["../../../src/Editing/Properties.ts"],"names":[],"mappings":";;;AAAA,gEAEoF;AAEpF,+CAA+C;AAU/C;;;GAGG;AACH,MAAa,UAAU;IACrB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,OAAO,CAAC,QAAuB,EAAE,YAAoB,EAAE,eAAuB;QACzF,MAAM,OAAO,GAAG,IAAI,0BAAM,CAAC,eAAe,CAAC,CAAC;QAE5C,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAkB,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEzF,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,IAAI,CAAoB,CAAC;QACxG,IAAI,YAAY;YACd,MAAM,IAAI,KAAK,CAAC,+BAA+B,eAAe,gCAAgC,YAAY,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;QAE5H,yBAAyB;QACzB,MAAM,iBAAiB,GAA2B,EAAE,CAAC;QACrD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,KAAqB,CAAC,CAAC;QAC7F,KAAK,MAAM,YAAY,IAAI,cAAc,EAAE;YACzC,IAAI,MAAM,YAAY,CAAC,WAAW,CAAC,eAAe,CAAC;gBACjD,MAAM,IAAI,KAAK,CAAC,+BAA+B,eAAe,gCAAgC,YAAY,CAAC,QAAQ,GAAG,CAAC,CAAC;YAE1H,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,YAAY,CAAoB,CAAC;YACzF,4DAA4D;YAC5D,IAAI,gBAAgB;gBAClB,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,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E,YAAY,CAAM,CAAC;QACjG,IAAI,CAAC,CAAC,QAAQ,YAAY,sCAAkB,CAAC,EAAC;YAC5C,qBAAqB;YACrB,MAAM,IAAI,KAAK,CAAC,gBAAgB,YAAY,+BAA+B,CAAC,CAAC;SAC9E;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlBD,oDAkBC;AAED;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,UAAU;IAC9C,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACgB,KAAK,CAAC,WAAW,CAAgC,QAAuB,EAAE,YAAoB;QAC/G,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,WAAW,CAAwB,QAAQ,EAAE,YAAY,CAAM,CAAC;QAC7F,IAAI,CAAC,CAAC,QAAQ,YAAY,kCAAc,CAAC,EAAC;YACxC,qBAAqB;YACrB,MAAM,IAAI,KAAK,CAAC,gBAAgB,YAAY,2BAA2B,CAAC,CAAC;SAC1E;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlBD,4CAkBC","sourcesContent":["import { CustomAttribute, DelayedPromiseWithProps, ECClass, ECName, ECObjectsError,\r\n ECObjectsStatus, EnumerationProperty, NavigationProperty, PrimitiveProperty,\r\n PropertyCategory, SchemaItemKey, StructProperty } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { MutableArrayProperty } from \"./Mutable/MutableArrayProperty\";\r\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\r\nimport { MutablePrimitiveOrEnumPropertyBase } from \"./Mutable/MutablePrimitiveOrEnumProperty\";\r\nimport { MutableClass } from \"./Mutable/MutableClass\";\r\nimport { MutableStructProperty } from \"./Mutable/MutableStructProperty\";\r\nimport { MutableNavigationProperty } from \"./Mutable/MutableNavigationProperty\";\r\n\r\ntype MutablePropertyType = MutableProperty | MutableArrayProperty | MutablePrimitiveOrEnumPropertyBase | MutableNavigationProperty | MutableStructProperty;\r\n\r\n/**\r\n * @alpha\r\n * A class allowing editing of attributes of the base Property class.\r\n */\r\nexport class Properties {\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n\r\n public async setName(classKey: SchemaItemKey, propertyName: string, newPropertyName: string) {\r\n const newName = new ECName(newPropertyName);\r\n\r\n const existingProperty = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n\r\n const baseProperty = await existingProperty.class.getProperty(newPropertyName, true) as MutableProperty;\r\n if (baseProperty)\r\n throw new Error(`An ECProperty with the name ${newPropertyName} already exists in the class ${baseProperty.class.name}.`);\r\n\r\n // Handle derived classes\r\n const derivedProperties: Array<MutableProperty> = [];\r\n const derivedClasses = await this.findDerivedClasses(existingProperty.class as MutableClass);\r\n for (const derivedClass of derivedClasses) {\r\n if (await derivedClass.getProperty(newPropertyName))\r\n throw new Error(`An ECProperty with the name ${newPropertyName} already exists in the class ${derivedClass.fullName}.`);\r\n\r\n const propertyOverride = await derivedClass.getProperty(propertyName) as MutableProperty;\r\n // If found the property is overridden in the derived class.\r\n if (propertyOverride)\r\n derivedProperties.push(propertyOverride);\r\n }\r\n\r\n // Re-name the overridden property in all derived classes\r\n derivedProperties.forEach((prop: MutableProperty) => {\r\n prop.setName(newName);\r\n });\r\n\r\n existingProperty.setName(newName);\r\n }\r\n\r\n /**\r\n * Sets the property description.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param description The new description to set.\r\n */\r\n public async setDescription(classKey: SchemaItemKey, propertyName: string, description: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setDescription(description);\r\n }\r\n\r\n /**\r\n * Sets the property label.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param label The new label to set.\r\n */\r\n public async setLabel(classKey: SchemaItemKey, propertyName: string, label: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setLabel(label);\r\n }\r\n\r\n /**\r\n * Sets the property isReadOnly attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param isReadOnly The new isReadOnly value.\r\n */\r\n public async setIsReadOnly(classKey: SchemaItemKey, propertyName: string, isReadOnly: boolean) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setIsReadOnly(isReadOnly);\r\n }\r\n\r\n /**\r\n * Sets the property priority.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param priority The new priority.\r\n */\r\n public async setPriority(classKey: SchemaItemKey, propertyName: string, priority: number) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setPriority(priority);\r\n }\r\n\r\n /**\r\n * Sets the property category.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param categoryKey The SchemaItemKey of the property category.\r\n */\r\n public async setCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n\r\n const category = await property.class.schema.lookupItem<PropertyCategory>(categoryKey);\r\n if (category === undefined) {\r\n return { errorMessage: `Can't locate the Property Category ${categoryKey.fullName} in the schema ${property.class.schema.fullName}.` };\r\n }\r\n\r\n property.setCategory(new DelayedPromiseWithProps<SchemaItemKey, PropertyCategory>(categoryKey, async () => category));\r\n return { itemKey: classKey, propertyName };\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\r\n * @param classKey The SchemaItemKey identifying the class.\r\n * @param propertyName The name of the property.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n\r\n property.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);\r\n\r\n // TODO: Update error\r\n const error = new Error();\r\n for await (const diagnostic of diagnostics) {\r\n error.message += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (error.message) {\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the property with the specified name from the class identified by the given key.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property to retrieve.\r\n */\r\n protected async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const mutableClass = await this.getClass(classKey);\r\n\r\n const property = await mutableClass.getProperty(propertyName) as T;\r\n if (property === undefined) {\r\n // TODO: Update error\r\n throw new Error(`An ECProperty with the name ${propertyName} could not be found in the class ${classKey.fullName}.`);\r\n }\r\n\r\n return property;\r\n }\r\n\r\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\r\n const derivedClasses: Array<MutableClass> = [];\r\n\r\n for await (const schemaItem of this._schemaEditor.schemaContext.getSchemaItems()) {\r\n if(ECClass.isECClass(schemaItem) && await schemaItem.is(mutableClass)) {\r\n if (!mutableClass.key.matches(schemaItem.key)) {\r\n derivedClasses.push(schemaItem as MutableClass);\r\n }\r\n }\r\n }\r\n\r\n return derivedClasses;\r\n }\r\n\r\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,`Schema Key ${classKey.schemaKey.toString(true)} not found in context`);\r\n\r\n const ecClass = await schema.getItem(classKey.name);\r\n if (ecClass === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);\r\n\r\n if (!(ecClass instanceof ECClass)) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\r\n }\r\n\r\n return ecClass as MutableClass;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveArrayProperty,\r\n * EnumerationArrayProperty and StructArrayProperty.\r\n */\r\nexport class ArrayProperties extends Properties {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the array property minOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minOccurs The new minOccurs value.\r\n */\r\n public async setMinOccurs(classKey: SchemaItemKey, propertyName: string, minOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName);\r\n property.setMinOccurs(minOccurs);\r\n }\r\n\r\n /**\r\n * Sets the array property maxOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxOccurs The new maxOccurs value.\r\n */\r\n public async setMaxOccurs(classKey: SchemaItemKey, propertyName: string, maxOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName);\r\n property.setMaxOccurs(maxOccurs);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is an ArrayProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableArrayProperty>(classKey, propertyName) as T;\r\n if (!property.isArray()){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not an ArrayProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveProperty and EnumerationProperty.\r\n */\r\nclass PrimitiveOrEnumProperties extends Properties {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the extendTypeName attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param extendTypeName The extended type name of the property.\r\n */\r\n public async setExtendedTypeName(classKey: SchemaItemKey, propertyName: string, extendedTypeName: string) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setExtendedTypeName(extendedTypeName);\r\n }\r\n\r\n /**\r\n * Sets the minLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minLength The minimum length of the property.\r\n */\r\n public async setMinLength(classKey: SchemaItemKey, propertyName: string, minLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMinLength(minLength);\r\n }\r\n\r\n /**\r\n * Sets the maxLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxLength The maximum length of the property.\r\n */\r\n public async setMaxLength(classKey: SchemaItemKey, propertyName: string, maxLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMaxLength(maxLength);\r\n }\r\n\r\n /**\r\n * Sets the minValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minValue The minimum value of the property.\r\n */\r\n public async setMinValue(classKey: SchemaItemKey, propertyName: string, minValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMinValue(minValue);\r\n }\r\n\r\n /**\r\n * Sets the maxValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxValue The maximum value of the property.\r\n */\r\n public async setMaxValue(classKey: SchemaItemKey, propertyName: string, maxValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMaxValue(maxValue);\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of PrimitiveProperty attributes.\r\n */\r\nexport class PrimitiveProperties extends PrimitiveOrEnumProperties {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a PrimitiveProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof PrimitiveProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not an PrimitiveProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of EnumerationProperty attributes.\r\n */\r\nexport class EnumerationProperties extends PrimitiveOrEnumProperties {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a EnumerationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof EnumerationProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not an EnumerationProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of NavigationProperties attributes.\r\n */\r\nexport class NavigationProperties extends Properties {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a NavigationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableNavigationProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof NavigationProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not a NavigationProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of StructProperty attributes.\r\n */\r\nexport class StructProperties extends Properties {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a StructProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableStructProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof StructProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not a StructProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n"]}
1
+ {"version":3,"file":"Properties.js","sourceRoot":"","sources":["../../../src/Editing/Properties.ts"],"names":[],"mappings":";;;AAAA,gEAEoG;AAEpG,+CAA+C;AAW/C;;;GAGG;AACH,MAAa,UAAU;IACrB,YAA6B,WAA+B,EAAY,aAAkC;QAA7E,gBAAW,GAAX,WAAW,CAAoB;QAAY,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAExG,KAAK,CAAC,OAAO,CAAC,QAAuB,EAAE,YAAoB,EAAE,eAAuB;QACzF,MAAM,OAAO,GAAG,IAAI,0BAAM,CAAC,eAAe,CAAC,CAAC;QAE5C,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAkB,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEzF,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,IAAI,CAAoB,CAAC;QACxG,IAAI,YAAY;YACd,MAAM,IAAI,KAAK,CAAC,+BAA+B,eAAe,gCAAgC,YAAY,CAAC,KAAK,C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AAgC,QAAuB,EAAE,YAAoB;QAC/G,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,WAAW,CAAwB,QAAQ,EAAE,YAAY,CAAM,CAAC;QAC7F,IAAI,CAAC,CAAC,QAAQ,YAAY,kCAAc,CAAC,EAAC;YACxC,qBAAqB;YACrB,MAAM,IAAI,KAAK,CAAC,gBAAgB,YAAY,2BAA2B,CAAC,CAAC;SAC1E;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlBD,4CAkBC","sourcesContent":["import { CustomAttribute, DelayedPromiseWithProps, ECClass, ECName, ECObjectsError,\r\n ECObjectsStatus, EnumerationProperty, NavigationProperty, PrimitiveProperty,\r\n PropertyCategory, SchemaItemKey, SchemaItemType, StructProperty } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { MutableArrayProperty } from \"./Mutable/MutableArrayProperty\";\r\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\r\nimport { MutablePrimitiveOrEnumPropertyBase } from \"./Mutable/MutablePrimitiveOrEnumProperty\";\r\nimport { MutableClass } from \"./Mutable/MutableClass\";\r\nimport { MutableStructProperty } from \"./Mutable/MutableStructProperty\";\r\nimport { MutableNavigationProperty } from \"./Mutable/MutableNavigationProperty\";\r\nimport { ECClassSchemaItems } from \"./ECClasses\";\r\n\r\ntype MutablePropertyType = MutableProperty | MutableArrayProperty | MutablePrimitiveOrEnumPropertyBase | MutableNavigationProperty | MutableStructProperty;\r\n\r\n/**\r\n * @alpha\r\n * A class allowing editing of attributes of the base Property class.\r\n */\r\nexport class Properties {\r\n public constructor(protected ecClassType: ECClassSchemaItems, protected _schemaEditor: SchemaContextEditor) { }\r\n\r\n public async setName(classKey: SchemaItemKey, propertyName: string, newPropertyName: string) {\r\n const newName = new ECName(newPropertyName);\r\n\r\n const existingProperty = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n\r\n const baseProperty = await existingProperty.class.getProperty(newPropertyName, true) as MutableProperty;\r\n if (baseProperty)\r\n throw new Error(`An ECProperty with the name ${newPropertyName} already exists in the class ${baseProperty.class.name}.`);\r\n\r\n // Handle derived classes\r\n const derivedProperties: Array<MutableProperty> = [];\r\n const derivedClasses = await this.findDerivedClasses(existingProperty.class as MutableClass);\r\n for (const derivedClass of derivedClasses) {\r\n if (await derivedClass.getProperty(newPropertyName))\r\n throw new Error(`An ECProperty with the name ${newPropertyName} already exists in the class ${derivedClass.fullName}.`);\r\n\r\n const propertyOverride = await derivedClass.getProperty(propertyName) as MutableProperty;\r\n // If found the property is overridden in the derived class.\r\n if (propertyOverride)\r\n derivedProperties.push(propertyOverride);\r\n }\r\n\r\n // Re-name the overridden property in all derived classes\r\n derivedProperties.forEach((prop: MutableProperty) => {\r\n prop.setName(newName);\r\n });\r\n\r\n existingProperty.setName(newName);\r\n }\r\n\r\n /**\r\n * Sets the property description.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param description The new description to set.\r\n */\r\n public async setDescription(classKey: SchemaItemKey, propertyName: string, description: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setDescription(description);\r\n }\r\n\r\n /**\r\n * Sets the property label.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param label The new label to set.\r\n */\r\n public async setLabel(classKey: SchemaItemKey, propertyName: string, label: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setLabel(label);\r\n }\r\n\r\n /**\r\n * Sets the property isReadOnly attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param isReadOnly The new isReadOnly value.\r\n */\r\n public async setIsReadOnly(classKey: SchemaItemKey, propertyName: string, isReadOnly: boolean) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setIsReadOnly(isReadOnly);\r\n }\r\n\r\n /**\r\n * Sets the property priority.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param priority The new priority.\r\n */\r\n public async setPriority(classKey: SchemaItemKey, propertyName: string, priority: number) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setPriority(priority);\r\n }\r\n\r\n /**\r\n * Sets the property category.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param categoryKey The SchemaItemKey of the property category.\r\n */\r\n public async setCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n\r\n const category = await property.class.schema.lookupItem<PropertyCategory>(categoryKey);\r\n if (category === undefined) {\r\n return { errorMessage: `Can't locate the Property Category ${categoryKey.fullName} in the schema ${property.class.schema.fullName}.` };\r\n }\r\n\r\n property.setCategory(new DelayedPromiseWithProps<SchemaItemKey, PropertyCategory>(categoryKey, async () => category));\r\n return { itemKey: classKey, propertyName };\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\r\n * @param classKey The SchemaItemKey identifying the class.\r\n * @param propertyName The name of the property.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n\r\n property.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);\r\n\r\n // TODO: Update error\r\n const error = new Error();\r\n for await (const diagnostic of diagnostics) {\r\n error.message += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (error.message) {\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the property with the specified name from the class identified by the given key.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property to retrieve.\r\n */\r\n protected async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const mutableClass = await this.getClass(classKey);\r\n\r\n if (mutableClass.schemaItemType !== this.ecClassType){\r\n throw new Error(`The class ${classKey.fullName} is not an ${SchemaItemType[this.ecClassType]}.`);\r\n }\r\n\r\n const property = await mutableClass.getProperty(propertyName) as T;\r\n if (property === undefined) {\r\n // TODO: Update error\r\n throw new Error(`An ECProperty with the name ${propertyName} could not be found in the class ${classKey.fullName}.`);\r\n }\r\n\r\n return property;\r\n }\r\n\r\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\r\n const derivedClasses: Array<MutableClass> = [];\r\n\r\n for await (const schemaItem of this._schemaEditor.schemaContext.getSchemaItems()) {\r\n if(ECClass.isECClass(schemaItem) && await schemaItem.is(mutableClass)) {\r\n if (!mutableClass.key.matches(schemaItem.key)) {\r\n derivedClasses.push(schemaItem as MutableClass);\r\n }\r\n }\r\n }\r\n\r\n return derivedClasses;\r\n }\r\n\r\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,`Schema Key ${classKey.schemaKey.toString(true)} not found in context`);\r\n\r\n const ecClass = await schema.getItem(classKey.name);\r\n if (ecClass === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);\r\n\r\n if (!(ecClass instanceof ECClass)) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\r\n }\r\n\r\n return ecClass as MutableClass;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveArrayProperty,\r\n * EnumerationArrayProperty and StructArrayProperty.\r\n */\r\nexport class ArrayProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the array property minOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minOccurs The new minOccurs value.\r\n */\r\n public async setMinOccurs(classKey: SchemaItemKey, propertyName: string, minOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName);\r\n property.setMinOccurs(minOccurs);\r\n }\r\n\r\n /**\r\n * Sets the array property maxOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxOccurs The new maxOccurs value.\r\n */\r\n public async setMaxOccurs(classKey: SchemaItemKey, propertyName: string, maxOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName);\r\n property.setMaxOccurs(maxOccurs);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is an ArrayProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableArrayProperty>(classKey, propertyName) as T;\r\n if (!property.isArray()){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not an ArrayProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveProperty and EnumerationProperty.\r\n */\r\nclass PrimitiveOrEnumProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the extendTypeName attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param extendTypeName The extended type name of the property.\r\n */\r\n public async setExtendedTypeName(classKey: SchemaItemKey, propertyName: string, extendedTypeName: string) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setExtendedTypeName(extendedTypeName);\r\n }\r\n\r\n /**\r\n * Sets the minLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minLength The minimum length of the property.\r\n */\r\n public async setMinLength(classKey: SchemaItemKey, propertyName: string, minLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMinLength(minLength);\r\n }\r\n\r\n /**\r\n * Sets the maxLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxLength The maximum length of the property.\r\n */\r\n public async setMaxLength(classKey: SchemaItemKey, propertyName: string, maxLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMaxLength(maxLength);\r\n }\r\n\r\n /**\r\n * Sets the minValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minValue The minimum value of the property.\r\n */\r\n public async setMinValue(classKey: SchemaItemKey, propertyName: string, minValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMinValue(minValue);\r\n }\r\n\r\n /**\r\n * Sets the maxValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxValue The maximum value of the property.\r\n */\r\n public async setMaxValue(classKey: SchemaItemKey, propertyName: string, maxValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMaxValue(maxValue);\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of PrimitiveProperty attributes.\r\n */\r\nexport class PrimitiveProperties extends PrimitiveOrEnumProperties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a PrimitiveProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof PrimitiveProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not an PrimitiveProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of EnumerationProperty attributes.\r\n */\r\nexport class EnumerationProperties extends PrimitiveOrEnumProperties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a EnumerationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof EnumerationProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not an EnumerationProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of NavigationProperties attributes.\r\n */\r\nexport class NavigationProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a NavigationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableNavigationProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof NavigationProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not a NavigationProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of StructProperty attributes.\r\n */\r\nexport class StructProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a StructProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableStructProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof StructProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not a StructProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n"]}
@@ -4,12 +4,17 @@
4
4
  import { CustomAttribute, ECClassModifier, EntityClass, Mixin, NavigationPropertyProps, RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaKey, StrengthDirection, StrengthType } from "@itwin/ecschema-metadata";
5
5
  import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
6
  import { ECClasses } from "./ECClasses";
7
+ import { NavigationProperties } from "./Properties";
7
8
  /**
8
9
  * @alpha
9
10
  * A class extending ECClasses allowing you to create schema items of type RelationshipClass.
10
11
  */
11
12
  export declare class RelationshipClasses extends ECClasses {
12
- constructor(_schemaEditor: SchemaContextEditor);
13
+ constructor(schemaEditor: SchemaContextEditor);
14
+ /**
15
+ * Allows access for editing of NavigationProperty attributes.
16
+ */
17
+ readonly navigationProperties: NavigationProperties;
13
18
  /**
14
19
  * Creates a RelationshipClass.
15
20
  * @param schemaKey a SchemaKey of the Schema that will house the new object.
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipClasses.d.ts","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"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O,CAAC,mBAAmB,CAAC;IAalM;;;;OAIG;IACU,iCAAiC,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAczI,yBAAyB,CAAC,UAAU,EAAE,sBAAsB,EAAE,YAAY,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMrI,wBAAwB,CAAC,UAAU,EAAE,sBAAsB,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMlH,4BAA4B,CAAC,UAAU,EAAE,sBAAsB,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMlI,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE,kBAAkB,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAyBvJ,kBAAkB,CAAC,UAAU,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAmBxI,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAa3I,8BAA8B,CAAC,UAAU,EAAE,sBAAsB,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAkBnI,QAAQ;CAoBvB"}
@@ -11,13 +11,18 @@ exports.RelationshipClasses = void 0;
11
11
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
12
  const ECClasses_1 = require("./ECClasses");
13
13
  const Rules = require("../Validation/ECRules");
14
+ const Properties_1 = require("./Properties");
14
15
  /**
15
16
  * @alpha
16
17
  * A class extending ECClasses allowing you to create schema items of type RelationshipClass.
17
18
  */
18
19
  class RelationshipClasses extends ECClasses_1.ECClasses {
19
- constructor(_schemaEditor) {
20
- super(_schemaEditor);
20
+ constructor(schemaEditor) {
21
+ super(ecschema_metadata_1.SchemaItemType.RelationshipClass, schemaEditor);
22
+ /**
23
+ * Allows access for editing of NavigationProperty attributes.
24
+ */
25
+ this.navigationProperties = new Properties_1.NavigationProperties(this.schemaItemType, this._schemaEditor);
21
26
  }
22
27
  /**
23
28
  * Creates a RelationshipClass.