@itwin/ecschema-editing 5.0.0-dev.59 → 5.0.0-dev.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +2 -2
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js +5 -5
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Editing/Constants.d.ts +2 -1
- package/lib/cjs/Editing/Constants.d.ts.map +1 -1
- package/lib/cjs/Editing/Constants.js +4 -1
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts +2 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js +3 -0
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +6 -0
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +23 -16
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +2 -2
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +13 -3
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +2 -1
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +14 -10
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.d.ts +2 -1
- package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
- package/lib/cjs/Editing/Enumerations.js +6 -3
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Formats.d.ts +2 -1
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +5 -1
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts +2 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js +10 -6
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +2 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +11 -7
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +2 -1
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +9 -5
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.d.ts +2 -1
- package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
- package/lib/cjs/Editing/Phenomena.js +3 -0
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/Properties.d.ts.map +1 -1
- package/lib/cjs/Editing/Properties.js +2 -2
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts +2 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js +5 -1
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +1 -0
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +9 -5
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.d.ts +2 -2
- package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js +6 -11
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Editing/Structs.d.ts +2 -1
- package/lib/cjs/Editing/Structs.d.ts.map +1 -1
- package/lib/cjs/Editing/Structs.js +3 -0
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.d.ts +2 -1
- package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js +3 -0
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.d.ts +2 -1
- package/lib/cjs/Editing/Units.d.ts.map +1 -1
- package/lib/cjs/Editing/Units.js +5 -2
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +1 -1
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +7 -2
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/FormatMerger.js +6 -1
- package/lib/cjs/Merging/FormatMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +3 -3
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +4 -4
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +4 -2
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/Utils.js +1 -1
- package/lib/cjs/Merging/Utils.js.map +1 -1
- package/lib/cjs/Validation/ECRules.js +1 -1
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js +19 -19
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts +2 -2
- package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +2 -2
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- 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;AAExC,6CAAoD;AACpD,2CAA2E;AAE3E;;;GAGG;AACH,MAAa,QAAS,SAAQ,qBAAS;IACrC,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACa,oBAAoB,GAAG,IAAI,iCAAoB,CAAC,kCAAc,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAExG,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAyB,EAAE,YAA2B,EAAE,YAAqB,EAAE,MAAgB;QAC5J,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YACzD,IAAI,CAAC,CAAC,MAAO,SAAyB,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;gBACjE,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,qBAAqB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;YACtH,CAAC;QACH,CAAC;QAAC,OAAM,CAAM,EAAC,CAAC;YACd,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,aAAa,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAA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;YACvE,MAAM,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QACvE,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,wBAAwB,EAAE,IAAI,mBAAO,CAAC,kCAAc,CAAC,iBAAiB,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACtI,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,iCAAiC,CAAC,QAAuB,EAAE,eAAwC;QAC9G,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAqB,QAAQ,CAAC,CAAC;YACtE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;YAC1I,MAAM,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,iCAAiC,EAAE,IAAI,mBAAO,CAAC,kCAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACxI,CAAC;IACH,CAAC;CACF;AAhHD,4BAgHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n ECClassModifier, EntityClass, EntityClassProps,\n Mixin, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaItemType, SchemaKey, StrengthDirection,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableEntityClass } from \"./Mutable/MutableEntityClass\";\nimport { NavigationProperties } from \"./Properties\";\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type EntityClass.\n */\nexport class Entities extends ECClasses {\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.EntityClass, schemaEditor);\n }\n\n /**\n * Allows access for editing of NavigationProperty attributes.\n */\n public readonly navigationProperties = new NavigationProperties(SchemaItemType.EntityClass, this.schemaEditor);\n\n public async createElement(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const baseClass = await this.getSchemaItem(baseClassKey);\n if (!(await (baseClass as EntityClass).is(\"Element\", \"BisCore\"))) {\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElement, new ClassId(this.schemaItemType, baseClassKey));\n }\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\n }\n\n public async createElementUniqueAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const baseClass = await this.getSchemaItem(baseClassKey);\n if (!(await (baseClass as EntityClass).is(\"ElementUniqueAspect\", \"BisCore\"))) {\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElementUniqueAspect, new ClassId(this.schemaItemType, baseClassKey));\n }\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\n }\n\n public async createElementMultiAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const baseClass = await this.getSchemaItem(baseClassKey);\n if (!(await (baseClass as EntityClass).is(\"ElementMultiAspect\", \"BisCore\"))) {\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElementMultiAspect, new ClassId(this.schemaItemType, baseClassKey));\n }\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\n }\n\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, displayLabel?: string, baseClassKey?: SchemaItemKey, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<EntityClass>(schemaKey, this.schemaItemType, (schema) => schema.createEntityClass.bind(schema), name, baseClassKey, modifier) as MutableEntityClass;\n\n if (mixins !== undefined)\n mixins.forEach((m) => newClass.addMixin(m));\n\n if (displayLabel)\n newClass.setDisplayLabel(displayLabel);\n\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n /**\n * Creates an EntityClass through an EntityClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param entityProps a json object that will be used to populate the new EntityClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, entityProps: EntityClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createEntityClass.bind(schema), entityProps);\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, entityProps.name!, schemaKey), e);\n }\n }\n\n public async addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void> {\n try {\n const entity = await this.getSchemaItem<MutableEntityClass>(entityKey);\n const mixin = await this.getSchemaItem<Mixin>(mixinKey, SchemaItemType.Mixin);\n entity.addMixin(mixin);\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.AddMixin, new ClassId(SchemaItemType.EntityClass, entityKey), e);\n }\n }\n\n public async createNavigationProperty(entityKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void> {\n try {\n const entity = await this.getSchemaItem<MutableEntityClass>(entityKey);\n await entity.createNavigationProperty(name, relationship, direction);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationProperty, new ClassId(SchemaItemType.RelationshipClass, entityKey), e);\n }\n }\n\n /**\n * Creates a Navigation Property through a NavigationPropertyProps.\n * @param classKey a SchemaItemKey of the Entity Class that will house the new property.\n * @param navigationProps a json object that will be used to populate the new Navigation Property.\n */\n public async createNavigationPropertyFromProps(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void> {\n try {\n const entity = await this.getSchemaItem<MutableEntityClass>(classKey);\n const property = await entity.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\n await property.fromJSON(navigationProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationPropertyFromProps, new ClassId(SchemaItemType.EntityClass, classKey), e);\n }\n }\n}\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;AACxC,qEAAkE;AAClE,6CAAoD;AACpD,2CAA2E;AAE3E;;;GAGG;AACH,MAAa,QAAS,SAAQ,qBAAS;IACrC,IAAuB,aAAa;QAClC,OAAO,+BAAW,CAAC;IACrB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACa,oBAAoB,GAAG,IAAI,iCAAoB,CAAC,kCAAc,CAAC,WAAW,EAAE,IAAI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,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;YAC1I,MAAM,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,iCAAiC,EAAE,IAAI,mBAAO,CAAC,kCAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACxI,CAAC;IACH,CAAC;CACF;AApHD,4BAoHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n ECClassModifier, EntityClass, EntityClassProps,\n Mixin, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaItemType, SchemaKey, StrengthDirection,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableEntityClass } from \"./Mutable/MutableEntityClass\";\nimport { NavigationProperties } from \"./Properties\";\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type EntityClass.\n */\nexport class Entities extends ECClasses {\n protected override get itemTypeClass(): typeof EntityClass {\n return EntityClass;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.EntityClass, schemaEditor);\n }\n\n /**\n * Allows access for editing of NavigationProperty attributes.\n */\n public readonly navigationProperties = new NavigationProperties(SchemaItemType.EntityClass, this.schemaEditor);\n\n public async createElement(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const baseClass = await this.getSchemaItem(baseClassKey, EntityClass);\n if (!(await (baseClass).is(\"Element\", \"BisCore\"))) {\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElement, new ClassId(this.schemaItemType, baseClassKey));\n }\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\n }\n\n public async createElementUniqueAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const baseClass = await this.getSchemaItem(baseClassKey, EntityClass);\n if (!(await (baseClass).is(\"ElementUniqueAspect\", \"BisCore\"))) {\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElementUniqueAspect, new ClassId(this.schemaItemType, baseClassKey));\n }\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\n }\n\n public async createElementMultiAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const baseClass = await this.getSchemaItem(baseClassKey, EntityClass);\n if (!(await (baseClass).is(\"ElementMultiAspect\", \"BisCore\"))) {\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElementMultiAspect, new ClassId(this.schemaItemType, baseClassKey));\n }\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\n }\n\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, displayLabel?: string, baseClassKey?: SchemaItemKey, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<EntityClass>(schemaKey, this.schemaItemType, (schema) => schema.createEntityClass.bind(schema), name, baseClassKey, modifier) as MutableEntityClass;\n\n if (mixins !== undefined)\n mixins.forEach((m) => newClass.addMixin(m));\n\n if (displayLabel)\n newClass.setDisplayLabel(displayLabel);\n\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n /**\n * Creates an EntityClass through an EntityClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param entityProps a json object that will be used to populate the new EntityClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, entityProps: EntityClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createEntityClass.bind(schema), entityProps);\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, entityProps.name!, schemaKey), e);\n }\n }\n\n public async addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void> {\n try {\n const entity = await this.getSchemaItem(entityKey, MutableEntityClass);\n const mixin = await this.getSchemaItem(mixinKey, Mixin);\n entity.addMixin(mixin);\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.AddMixin, new ClassId(SchemaItemType.EntityClass, entityKey), e);\n }\n }\n\n public async createNavigationProperty(entityKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void> {\n try {\n const entity = await this.getSchemaItem(entityKey, MutableEntityClass);\n await entity.createNavigationProperty(name, relationship, direction);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationProperty, new ClassId(SchemaItemType.RelationshipClass, entityKey), e);\n }\n }\n\n /**\n * Creates a Navigation Property through a NavigationPropertyProps.\n * @param classKey a SchemaItemKey of the Entity Class that will house the new property.\n * @param navigationProps a json object that will be used to populate the new Navigation Property.\n */\n public async createNavigationPropertyFromProps(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void> {\n try {\n const entity = await this.getSchemaItem(classKey, MutableEntityClass);\n const property = await entity.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\n await property.fromJSON(navigationProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationPropertyFromProps, new ClassId(SchemaItemType.EntityClass, classKey), e);\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
|
-
import { AnyEnumerator, EnumerationProps, PrimitiveType, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
4
|
+
import { AnyEnumerator, Enumeration, EnumerationProps, PrimitiveType, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
5
|
import { SchemaContextEditor } from "./Editor";
|
|
6
6
|
import { SchemaItems } from "./SchemaItems";
|
|
7
7
|
/**
|
|
@@ -9,6 +9,7 @@ import { SchemaItems } from "./SchemaItems";
|
|
|
9
9
|
* A class allowing you to create schema items of type Enumeration.
|
|
10
10
|
*/
|
|
11
11
|
export declare class Enumerations extends SchemaItems {
|
|
12
|
+
protected get itemTypeClass(): typeof Enumeration;
|
|
12
13
|
constructor(schemaEditor: SchemaContextEditor);
|
|
13
14
|
create(schemaKey: SchemaKey, name: string, type: PrimitiveType.Integer | PrimitiveType.String, displayLabel?: string, isStrict?: boolean, enumerators?: AnyEnumerator[]): Promise<SchemaItemKey>;
|
|
14
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enumerations.d.ts","sourceRoot":"","sources":["../../../src/Editing/Enumerations.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"Enumerations.d.ts","sourceRoot":"","sources":["../../../src/Editing/Enumerations.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAkB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjJ,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAM5C;;;GAGG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC3C,cAAuB,aAAa,IAAI,OAAO,WAAW,CAEzD;gBAEkB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAoB7M;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAS1F,aAAa,CAAC,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBtF,kBAAkB,CAAC,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAcnH,wBAAwB,CAAC,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAa7I"}
|
|
@@ -16,6 +16,9 @@ const SchemaItems_1 = require("./SchemaItems");
|
|
|
16
16
|
* A class allowing you to create schema items of type Enumeration.
|
|
17
17
|
*/
|
|
18
18
|
class Enumerations extends SchemaItems_1.SchemaItems {
|
|
19
|
+
get itemTypeClass() {
|
|
20
|
+
return ecschema_metadata_1.Enumeration;
|
|
21
|
+
}
|
|
19
22
|
constructor(schemaEditor) {
|
|
20
23
|
super(ecschema_metadata_1.SchemaItemType.Enumeration, schemaEditor);
|
|
21
24
|
}
|
|
@@ -51,7 +54,7 @@ class Enumerations extends SchemaItems_1.SchemaItems {
|
|
|
51
54
|
}
|
|
52
55
|
async addEnumerator(enumerationKey, enumerator) {
|
|
53
56
|
try {
|
|
54
|
-
const enumeration = await this.getSchemaItem(enumerationKey, ecschema_metadata_1.
|
|
57
|
+
const enumeration = await this.getSchemaItem(enumerationKey, ecschema_metadata_1.Enumeration);
|
|
55
58
|
if (enumeration.isInt && typeof (enumerator.value) !== "number")
|
|
56
59
|
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidEnumeratorType, new Exception_1.EnumeratorId(enumerator, enumeration));
|
|
57
60
|
if (enumeration.isString && typeof (enumerator.value) !== "string")
|
|
@@ -64,7 +67,7 @@ class Enumerations extends SchemaItems_1.SchemaItems {
|
|
|
64
67
|
}
|
|
65
68
|
async setEnumeratorLabel(enumerationKey, enumeratorName, label) {
|
|
66
69
|
try {
|
|
67
|
-
const enumeration = await this.getSchemaItem(enumerationKey, ecschema_metadata_1.
|
|
70
|
+
const enumeration = await this.getSchemaItem(enumerationKey, ecschema_metadata_1.Enumeration);
|
|
68
71
|
const enumerator = enumeration.getEnumeratorByName(enumeratorName);
|
|
69
72
|
if (enumerator === undefined)
|
|
70
73
|
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.EnumeratorDoesNotExist, new Exception_1.EnumeratorId(enumeratorName, enumeration));
|
|
@@ -76,7 +79,7 @@ class Enumerations extends SchemaItems_1.SchemaItems {
|
|
|
76
79
|
}
|
|
77
80
|
async setEnumeratorDescription(enumerationKey, enumeratorName, description) {
|
|
78
81
|
try {
|
|
79
|
-
const enumeration = await this.getSchemaItem(enumerationKey, ecschema_metadata_1.
|
|
82
|
+
const enumeration = await this.getSchemaItem(enumerationKey, ecschema_metadata_1.Enumeration);
|
|
80
83
|
const enumerator = enumeration.getEnumeratorByName(enumeratorName);
|
|
81
84
|
if (enumerator === undefined)
|
|
82
85
|
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.EnumeratorDoesNotExist, new Exception_1.EnumeratorId(enumeratorName, enumeration));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enumerations.js","sourceRoot":"","sources":["../../../src/Editing/Enumerations.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiJ;AAGjJ,2CAA8F;AAC9F,+CAA4C;AAM5C;;;GAGG;AACH,MAAa,YAAa,SAAQ,yBAAW;IAC3C,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,IAAkD,EAAE,YAAqB,EAAE,QAAkB,EAAE,WAA6B;QAClL,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAc,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAuB,CAAC;YAE9K,IAAI,SAAS,KAAK,QAAQ;gBACxB,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAEhC,IAAI,SAAS,KAAK,WAAW;gBAC3B,KAAK,MAAM,UAAU,IAAI,WAAW;oBAClC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;YAEtD,IAAI,YAAY;gBACd,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAExC,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAA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,CAAC,CAAC;YACnE,IAAI,UAAU,KAAK,SAAS;gBAC1B,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,CAAC;YAErH,UAAgC,CAAC,KAAK,GAAG,KAAK,CAAC;QAClD,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,kBAAkB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,wBAAwB,CAAC,cAA6B,EAAE,cAAsB,EAAE,WAA+B;QAC1H,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,+BAAW,CAAC,CAAC;YAE1E,MAAM,UAAU,GAAG,WAAW,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;YACnE,IAAI,UAAU,KAAK,SAAS;gBAC1B,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,CAAC;YAErH,UAAgC,CAAC,WAAW,GAAG,WAAW,CAAC;QAC9D,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,kBAAkB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;CACF;AAtFD,oCAsFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { AnyEnumerator, Enumeration, EnumerationProps, PrimitiveType, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableEnumeration } from \"./Mutable/MutableEnumeration\";\nimport { ECEditingStatus, EnumeratorId, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\ntype MutableEnumerator = {\n -readonly [P in keyof AnyEnumerator]: AnyEnumerator[P]\n};\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Enumeration.\n */\nexport class Enumerations extends SchemaItems {\n protected override get itemTypeClass(): typeof Enumeration {\n return Enumeration;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Enumeration, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, type: PrimitiveType.Integer | PrimitiveType.String, displayLabel?: string, isStrict?: boolean, enumerators?: AnyEnumerator[]): Promise<SchemaItemKey> {\n try {\n const newEnum = await this.createSchemaItem<Enumeration>(schemaKey, this.schemaItemType, (schema) => schema.createEnumeration.bind(schema), name, type) as MutableEnumeration;\n\n if (undefined !== isStrict)\n newEnum.setIsStrict(isStrict);\n\n if (undefined !== enumerators)\n for (const enumerator of enumerators)\n await this.addEnumerator(newEnum.key, enumerator);\n\n if (displayLabel)\n newEnum.setDisplayLabel(displayLabel);\n\n return newEnum.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n /**\n * Creates an Enumeration through an EnumeratorProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, enumProps: EnumerationProps): Promise<SchemaItemKey> {\n try {\n const newEnum = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createEnumeration.bind(schema), enumProps);\n return newEnum.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, enumProps.name!, schemaKey), e);\n }\n }\n\n public async addEnumerator(enumerationKey: SchemaItemKey, enumerator: AnyEnumerator): Promise<void> {\n try {\n const enumeration = await this.getSchemaItem(enumerationKey, Enumeration);\n\n if (enumeration.isInt && typeof (enumerator.value) !== \"number\")\n throw new SchemaEditingError(ECEditingStatus.InvalidEnumeratorType, new EnumeratorId(enumerator, enumeration));\n\n if (enumeration.isString && typeof (enumerator.value) !== \"string\")\n throw new SchemaEditingError(ECEditingStatus.InvalidEnumeratorType, new EnumeratorId(enumerator, enumeration));\n\n (enumeration as MutableEnumeration).addEnumerator(enumerator);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddEnumerator, new SchemaItemId(this.schemaItemType, enumerationKey), e);\n }\n }\n\n public async setEnumeratorLabel(enumerationKey: SchemaItemKey, enumeratorName: string, label: string | undefined): Promise<void> {\n try {\n const enumeration = await this.getSchemaItem(enumerationKey, Enumeration);\n\n const enumerator = enumeration.getEnumeratorByName(enumeratorName);\n if (enumerator === undefined)\n throw new SchemaEditingError(ECEditingStatus.EnumeratorDoesNotExist, new EnumeratorId(enumeratorName, enumeration));\n\n (enumerator as MutableEnumerator).label = label;\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetEnumeratorLabel, new SchemaItemId(this.schemaItemType, enumerationKey), e);\n }\n }\n\n public async setEnumeratorDescription(enumerationKey: SchemaItemKey, enumeratorName: string, description: string | undefined): Promise<void> {\n try {\n const enumeration = await this.getSchemaItem(enumerationKey, Enumeration);\n\n const enumerator = enumeration.getEnumeratorByName(enumeratorName);\n if (enumerator === undefined)\n throw new SchemaEditingError(ECEditingStatus.EnumeratorDoesNotExist, new EnumeratorId(enumeratorName, enumeration));\n\n (enumerator as MutableEnumerator).description = description;\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetEnumeratorLabel, new SchemaItemId(this.schemaItemType, enumerationKey), e);\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
|
-
import { SchemaItemFormatProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
4
|
+
import { Format, SchemaItemFormatProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
5
|
import { FormatType } from "@itwin/core-quantity";
|
|
6
6
|
import { SchemaContextEditor } from "./Editor";
|
|
7
7
|
import { SchemaItems } from "./SchemaItems";
|
|
@@ -10,6 +10,7 @@ import { SchemaItems } from "./SchemaItems";
|
|
|
10
10
|
* A class allowing you to create schema items of type Format.
|
|
11
11
|
*/
|
|
12
12
|
export declare class Formats extends SchemaItems {
|
|
13
|
+
protected get itemTypeClass(): typeof Format;
|
|
13
14
|
constructor(schemaEditor: SchemaContextEditor);
|
|
14
15
|
create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemKey>;
|
|
15
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formats.d.ts","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"Formats.d.ts","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAgB,qBAAqB,EAAE,aAAa,EAAkB,SAAS,EAAQ,MAAM,0BAA0B,CAAC;AACvI,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,OAAQ,SAAQ,WAAW;IACtC,cAAuB,aAAa,IAAI,OAAO,MAAM,CAEpD;gBAEkB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IA8BvJ;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ/G"}
|
|
@@ -16,6 +16,9 @@ const SchemaItems_1 = require("./SchemaItems");
|
|
|
16
16
|
* A class allowing you to create schema items of type Format.
|
|
17
17
|
*/
|
|
18
18
|
class Formats extends SchemaItems_1.SchemaItems {
|
|
19
|
+
get itemTypeClass() {
|
|
20
|
+
return ecschema_metadata_1.Format;
|
|
21
|
+
}
|
|
19
22
|
constructor(schemaEditor) {
|
|
20
23
|
super(ecschema_metadata_1.SchemaItemType.Format, schemaEditor);
|
|
21
24
|
}
|
|
@@ -28,8 +31,9 @@ class Formats extends SchemaItems_1.SchemaItems {
|
|
|
28
31
|
if (!unitItem) {
|
|
29
32
|
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNotFoundInContext, new Exception_1.SchemaItemId(ecschema_metadata_1.SchemaItemType.Unit, unit));
|
|
30
33
|
}
|
|
31
|
-
if (
|
|
34
|
+
if (!ecschema_metadata_1.Unit.isUnit(unitItem) && !ecschema_metadata_1.InvertedUnit.isInvertedUnit(unitItem)) {
|
|
32
35
|
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidFormatUnitsSpecified, new Exception_1.SchemaItemId(unitItem.schemaItemType, unitItem.key));
|
|
36
|
+
}
|
|
33
37
|
newFormat.addUnit(unitItem);
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAuI;AAIvI,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,OAAQ,SAAQ,yBAAW;IACtC,IAAuB,aAAa;QAClC,OAAO,0BAAM,CAAC;IAChB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAsB,EAAE,YAAqB,EAAE,KAAuB;QAC5H,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAS,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAkB,CAAC;YAE3J,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,MAAM,QAAQ,GAAI,MAAM,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;oBAC5E,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACd,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,2BAA2B,EAAE,IAAI,wBAAY,CAAC,kCAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;oBACzH,CAAC;oBAED,IAAI,CAAC,wBAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,gCAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;wBACrE,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,2BAA2B,EAAE,IAAI,wBAAY,CAAC,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;oBACrI,CAAC;oBAED,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;YAED,IAAI,YAAY;gBACd,SAAS,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAE1C,iEAAiE;YACjE,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YACpC,OAAO,SAAS,CAAC,GAAG,CAAC;QACvB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAAkC;QACnF,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;YAClJ,OAAO,SAAS,CAAC,GAAG,CAAC;QACvB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClJ,CAAC;IACH,CAAC;CACF;AApDD,0BAoDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { Format, InvertedUnit, SchemaItemFormatProps, SchemaItemKey, SchemaItemType, SchemaKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatType } from \"@itwin/core-quantity\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableFormat } from \"./Mutable/MutableFormat\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Format.\n */\nexport class Formats extends SchemaItems {\n protected override get itemTypeClass(): typeof Format {\n return Format;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Format, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemKey> {\n try {\n const newFormat = await this.createSchemaItem<Format>(schemaKey, this.schemaItemType, (schema) => schema.createFormat.bind(schema), name) as MutableFormat;\n\n if (units !== undefined) {\n for (const unit of units) {\n const unitItem = await this.schemaEditor.schemaContext.getSchemaItem(unit);\n if (!unitItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFoundInContext, new SchemaItemId(SchemaItemType.Unit, unit));\n }\n\n if (!Unit.isUnit(unitItem) && !InvertedUnit.isInvertedUnit(unitItem)) {\n throw new SchemaEditingError(ECEditingStatus.InvalidFormatUnitsSpecified, new SchemaItemId(unitItem.schemaItemType, unitItem.key));\n }\n\n newFormat.addUnit(unitItem);\n }\n }\n\n if (displayLabel)\n newFormat.setDisplayLabel(displayLabel);\n\n // TODO: Handle the setting of format traits, separators, etc....\n newFormat.setFormatType(formatType);\n return newFormat.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n /**\n * Creates a format through a SchemaItemFormatProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, formatProps: SchemaItemFormatProps): Promise<SchemaItemKey> {\n try {\n const newFormat = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createFormat.bind(schema), formatProps);\n return newFormat.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, formatProps.name!, schemaKey), e);\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
|
-
import { InvertedUnitProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
4
|
+
import { InvertedUnit, InvertedUnitProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
5
|
import { SchemaContextEditor } from "./Editor";
|
|
6
6
|
import { SchemaItems } from "./SchemaItems";
|
|
7
7
|
/**
|
|
@@ -9,6 +9,7 @@ import { SchemaItems } from "./SchemaItems";
|
|
|
9
9
|
* A class allowing you to create schema items of type Inverted Unit.
|
|
10
10
|
*/
|
|
11
11
|
export declare class InvertedUnits extends SchemaItems {
|
|
12
|
+
protected get itemTypeClass(): typeof InvertedUnit;
|
|
12
13
|
constructor(schemaEditor: SchemaContextEditor);
|
|
13
14
|
create(schemaKey: SchemaKey, name: string, invertsUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey>;
|
|
14
15
|
createFromProps(schemaKey: SchemaKey, invertedUnitProps: InvertedUnitProps): Promise<SchemaItemKey>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvertedUnits.d.ts","sourceRoot":"","sources":["../../../src/Editing/InvertedUnits.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"InvertedUnits.d.ts","sourceRoot":"","sources":["../../../src/Editing/InvertedUnits.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACoB,YAAY,EAAE,iBAAiB,EAAE,aAAa,EACvD,SAAS,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,cAAuB,aAAa,IAAI,OAAO,YAAY,CAE1D;gBAEkB,YAAY,EAAE,mBAAmB;IAGvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBtJ,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IASnG,cAAc,CAAC,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAU5F,aAAa,CAAC,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CASxG"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.InvertedUnits = void 0;
|
|
11
11
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const MutableInvertedUnit_1 = require("./Mutable/MutableInvertedUnit");
|
|
12
13
|
const Exception_1 = require("./Exception");
|
|
13
14
|
const SchemaItems_1 = require("./SchemaItems");
|
|
14
15
|
/**
|
|
@@ -16,15 +17,18 @@ const SchemaItems_1 = require("./SchemaItems");
|
|
|
16
17
|
* A class allowing you to create schema items of type Inverted Unit.
|
|
17
18
|
*/
|
|
18
19
|
class InvertedUnits extends SchemaItems_1.SchemaItems {
|
|
20
|
+
get itemTypeClass() {
|
|
21
|
+
return ecschema_metadata_1.InvertedUnit;
|
|
22
|
+
}
|
|
19
23
|
constructor(schemaEditor) {
|
|
20
24
|
super(ecschema_metadata_1.SchemaItemType.InvertedUnit, schemaEditor);
|
|
21
25
|
}
|
|
22
26
|
async create(schemaKey, name, invertsUnitKey, unitSystemKey, displayLabel) {
|
|
23
27
|
try {
|
|
24
28
|
const newUnit = await this.createSchemaItem(schemaKey, this.schemaItemType, (schema) => schema.createInvertedUnit.bind(schema), name);
|
|
25
|
-
const invertsUnit = await this.
|
|
29
|
+
const invertsUnit = await this.getSchemaItem(invertsUnitKey, ecschema_metadata_1.Unit);
|
|
26
30
|
newUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
|
|
27
|
-
const unitSystem = await this.
|
|
31
|
+
const unitSystem = await this.getSchemaItem(unitSystemKey, ecschema_metadata_1.UnitSystem);
|
|
28
32
|
newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
|
|
29
33
|
if (displayLabel)
|
|
30
34
|
newUnit.setDisplayLabel(displayLabel);
|
|
@@ -45,8 +49,8 @@ class InvertedUnits extends SchemaItems_1.SchemaItems {
|
|
|
45
49
|
}
|
|
46
50
|
async setInvertsUnit(invertedUnitKey, invertsUnitKey) {
|
|
47
51
|
try {
|
|
48
|
-
const invertedUnit = await this.getSchemaItem(invertedUnitKey);
|
|
49
|
-
const invertsUnit = await this.getSchemaItem(invertedUnitKey, ecschema_metadata_1.
|
|
52
|
+
const invertedUnit = await this.getSchemaItem(invertedUnitKey, MutableInvertedUnit_1.MutableInvertedUnit);
|
|
53
|
+
const invertsUnit = await this.getSchemaItem(invertedUnitKey, ecschema_metadata_1.Unit);
|
|
50
54
|
invertedUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
|
|
51
55
|
}
|
|
52
56
|
catch (e) {
|
|
@@ -55,8 +59,8 @@ class InvertedUnits extends SchemaItems_1.SchemaItems {
|
|
|
55
59
|
}
|
|
56
60
|
async setUnitSystem(invertedUnitKey, unitSystemKey) {
|
|
57
61
|
try {
|
|
58
|
-
const invertedUnit = await this.getSchemaItem(invertedUnitKey);
|
|
59
|
-
const unitSystem = await this.getSchemaItem(unitSystemKey, ecschema_metadata_1.
|
|
62
|
+
const invertedUnit = await this.getSchemaItem(invertedUnitKey, MutableInvertedUnit_1.MutableInvertedUnit);
|
|
63
|
+
const unitSystem = await this.getSchemaItem(unitSystemKey, ecschema_metadata_1.UnitSystem);
|
|
60
64
|
invertedUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
|
|
61
65
|
}
|
|
62
66
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvertedUnits.js","sourceRoot":"","sources":["../../../src/Editing/InvertedUnits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;
|
|
1
|
+
{"version":3,"file":"InvertedUnits.js","sourceRoot":"","sources":["../../../src/Editing/InvertedUnits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAElC,uEAAoE;AACpE,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,aAAc,SAAQ,yBAAW;IAC5C,IAAuB,aAAa;QAClC,OAAO,gCAAY,CAAC;IACtB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACnD,CAAC;IACM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,cAA6B,EAAE,aAA4B,EA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,CAAC,aAAa,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACzH,CAAC;IACH,CAAC;CACF;AAvDD,sCAuDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n DelayedPromiseWithProps, InvertedUnit, InvertedUnitProps, SchemaItemKey,\n SchemaItemType, SchemaKey, Unit, UnitSystem,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableInvertedUnit } from \"./Mutable/MutableInvertedUnit\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Inverted Unit.\n */\nexport class InvertedUnits extends SchemaItems {\n protected override get itemTypeClass(): typeof InvertedUnit {\n return InvertedUnit;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.InvertedUnit, schemaEditor);\n }\n public async create(schemaKey: SchemaKey, name: string, invertsUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItem<InvertedUnit>(schemaKey, this.schemaItemType, (schema) => schema.createInvertedUnit.bind(schema), name) as MutableInvertedUnit;\n\n const invertsUnit = await this.getSchemaItem(invertsUnitKey, Unit);\n newUnit.setInvertsUnit(new DelayedPromiseWithProps<SchemaItemKey, Unit>(invertsUnitKey, async () => invertsUnit));\n\n const unitSystem = await this.getSchemaItem(unitSystemKey, UnitSystem);\n newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemKey, async () => unitSystem));\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, invertedUnitProps: InvertedUnitProps): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createInvertedUnit.bind(schema), invertedUnitProps);\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, invertedUnitProps.name!, schemaKey), e);\n }\n }\n\n public async setInvertsUnit(invertedUnitKey: SchemaItemKey, invertsUnitKey: SchemaItemKey): Promise<void> {\n try {\n const invertedUnit = await this.getSchemaItem(invertedUnitKey, MutableInvertedUnit);\n const invertsUnit = await this.getSchemaItem(invertedUnitKey, Unit);\n invertedUnit.setInvertsUnit(new DelayedPromiseWithProps<SchemaItemKey, Unit>(invertsUnitKey, async () => invertsUnit));\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetInvertsUnit, new SchemaItemId(this.schemaItemType, invertedUnitKey), e);\n }\n }\n\n public async setUnitSystem(invertedUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey): Promise<void> {\n try {\n const invertedUnit = await this.getSchemaItem(invertedUnitKey, MutableInvertedUnit);\n const unitSystem = await this.getSchemaItem(unitSystemKey, UnitSystem);\n invertedUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemKey, async () => unitSystem));\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetUnitSystem, new SchemaItemId(this.schemaItemType, invertedUnitKey), e);\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
|
-
import { InvertedUnit, KindOfQuantityProps, OverrideFormat, SchemaItemKey, SchemaKey, Unit } from "@itwin/ecschema-metadata";
|
|
4
|
+
import { InvertedUnit, KindOfQuantity, KindOfQuantityProps, OverrideFormat, SchemaItemKey, SchemaKey, Unit } from "@itwin/ecschema-metadata";
|
|
5
5
|
import { SchemaContextEditor } from "./Editor";
|
|
6
6
|
import { SchemaItems } from "./SchemaItems";
|
|
7
7
|
/**
|
|
@@ -9,6 +9,7 @@ import { SchemaItems } from "./SchemaItems";
|
|
|
9
9
|
* A class allowing you to create schema items of type KindOfQuantity.
|
|
10
10
|
*/
|
|
11
11
|
export declare class KindOfQuantities extends SchemaItems {
|
|
12
|
+
protected get itemTypeClass(): typeof KindOfQuantity;
|
|
12
13
|
constructor(schemaEditor: SchemaContextEditor);
|
|
13
14
|
create(schemaKey: SchemaKey, name: string, persistenceUnitKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey>;
|
|
14
15
|
createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemKey>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantities.d.ts","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAEG,YAAY,
|
|
1
|
+
{"version":3,"file":"KindOfQuantities.d.ts","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAEG,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EACzE,aAAa,EAAkB,SAAS,EAAE,IAAI,EAC/C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,cAAuB,aAAa,IAAI,OAAO,cAAc,CAE5D;gBACkB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAyB5H,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IASzG;;;;;OAKG;IACU,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9G,6BAA6B,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5I;;;OAGG;IACU,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;CAQ7K"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.KindOfQuantities = void 0;
|
|
11
11
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const MutableKindOfQuantity_1 = require("./Mutable/MutableKindOfQuantity");
|
|
12
13
|
const Exception_1 = require("./Exception");
|
|
13
14
|
const SchemaItems_1 = require("./SchemaItems");
|
|
14
15
|
/**
|
|
@@ -16,6 +17,9 @@ const SchemaItems_1 = require("./SchemaItems");
|
|
|
16
17
|
* A class allowing you to create schema items of type KindOfQuantity.
|
|
17
18
|
*/
|
|
18
19
|
class KindOfQuantities extends SchemaItems_1.SchemaItems {
|
|
20
|
+
get itemTypeClass() {
|
|
21
|
+
return ecschema_metadata_1.KindOfQuantity;
|
|
22
|
+
}
|
|
19
23
|
constructor(schemaEditor) {
|
|
20
24
|
super(ecschema_metadata_1.SchemaItemType.KindOfQuantity, schemaEditor);
|
|
21
25
|
}
|
|
@@ -23,12 +27,12 @@ class KindOfQuantities extends SchemaItems_1.SchemaItems {
|
|
|
23
27
|
try {
|
|
24
28
|
const koqItem = await this.createSchemaItem(schemaKey, this.schemaItemType, (schema) => schema.createKindOfQuantity.bind(schema), name);
|
|
25
29
|
const persistenceUnit = await koqItem.schema.lookupItem(persistenceUnitKey);
|
|
26
|
-
if (persistenceUnit === undefined)
|
|
30
|
+
if (persistenceUnit === undefined || (!ecschema_metadata_1.Unit.isUnit(persistenceUnit) && !ecschema_metadata_1.InvertedUnit.isInvertedUnit(persistenceUnit)))
|
|
27
31
|
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNotFound, new Exception_1.SchemaItemId(ecschema_metadata_1.SchemaItemType.Unit, persistenceUnitKey));
|
|
28
|
-
if (
|
|
32
|
+
if (ecschema_metadata_1.Unit.isUnit(persistenceUnit)) {
|
|
29
33
|
koqItem.persistenceUnit = new ecschema_metadata_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
30
34
|
}
|
|
31
|
-
if (
|
|
35
|
+
if (ecschema_metadata_1.InvertedUnit.isInvertedUnit(persistenceUnit)) {
|
|
32
36
|
koqItem.persistenceUnit = new ecschema_metadata_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
33
37
|
}
|
|
34
38
|
if (displayLabel !== undefined) {
|
|
@@ -57,8 +61,8 @@ class KindOfQuantities extends SchemaItems_1.SchemaItems {
|
|
|
57
61
|
*/
|
|
58
62
|
async addPresentationFormat(koqKey, format, isDefault = false) {
|
|
59
63
|
try {
|
|
60
|
-
const kindOfQuantity = await this.getSchemaItem(koqKey);
|
|
61
|
-
const presentationFormat = await this.getSchemaItem(format, ecschema_metadata_1.
|
|
64
|
+
const kindOfQuantity = await this.getSchemaItem(koqKey, MutableKindOfQuantity_1.MutableKindOfQuantity);
|
|
65
|
+
const presentationFormat = await this.getSchemaItem(format, ecschema_metadata_1.Format);
|
|
62
66
|
kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);
|
|
63
67
|
}
|
|
64
68
|
catch (e) {
|
|
@@ -67,7 +71,7 @@ class KindOfQuantities extends SchemaItems_1.SchemaItems {
|
|
|
67
71
|
}
|
|
68
72
|
async addPresentationOverrideFormat(koqKey, overrideFormat, isDefault = false) {
|
|
69
73
|
try {
|
|
70
|
-
const kindOfQuantity = await this.getSchemaItem(koqKey);
|
|
74
|
+
const kindOfQuantity = await this.getSchemaItem(koqKey, MutableKindOfQuantity_1.MutableKindOfQuantity);
|
|
71
75
|
kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);
|
|
72
76
|
}
|
|
73
77
|
catch (e) {
|
|
@@ -80,7 +84,7 @@ class KindOfQuantities extends SchemaItems_1.SchemaItems {
|
|
|
80
84
|
*/
|
|
81
85
|
async createFormatOverride(parent, precision, unitLabelOverrides) {
|
|
82
86
|
try {
|
|
83
|
-
const parentFormat = await this.getSchemaItem(parent, ecschema_metadata_1.
|
|
87
|
+
const parentFormat = await this.getSchemaItem(parent, ecschema_metadata_1.Format);
|
|
84
88
|
return new ecschema_metadata_1.OverrideFormat(parentFormat, precision, unitLabelOverrides);
|
|
85
89
|
}
|
|
86
90
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantities.js","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAIkC;
|
|
1
|
+
{"version":3,"file":"KindOfQuantities.js","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAIkC;AAElC,2EAAwE;AACxE,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,gBAAiB,S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AAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,mBAAmB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACtH,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,6BAA6B,CAAC,MAAqB,EAAE,cAA8B,EAAE,YAAqB,KAAK;QAC1H,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,6CAAqB,CAAC,CAAC;YAC/E,cAAc,CAAC,qBAAqB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAClE,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,uBAAuB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1H,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,oBAAoB,CAAC,MAAqB,EAAE,SAAkB,EAAE,kBAAqE;QAChJ,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,0BAAM,CAAC,CAAC;YAC9D,OAAO,IAAI,kCAAc,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;QACzE,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,oBAAoB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACvH,CAAC;IACH,CAAC;CACF;AA/ED,4CA+EC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n DelayedPromiseWithProps,\n Format, InvertedUnit, KindOfQuantity, KindOfQuantityProps, OverrideFormat,\n SchemaItemKey, SchemaItemType, SchemaKey, Unit,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableKindOfQuantity } from \"./Mutable/MutableKindOfQuantity\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type KindOfQuantity.\n */\nexport class KindOfQuantities extends SchemaItems {\n protected override get itemTypeClass(): typeof KindOfQuantity {\n return KindOfQuantity;\n }\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.KindOfQuantity, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, persistenceUnitKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const koqItem = await this.createSchemaItem<KindOfQuantity>(schemaKey, this.schemaItemType, (schema) => schema.createKindOfQuantity.bind(schema), name) as MutableKindOfQuantity;\n const persistenceUnit = await koqItem.schema.lookupItem(persistenceUnitKey);\n if (persistenceUnit === undefined || (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit)))\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(SchemaItemType.Unit, persistenceUnitKey));\n\n if (Unit.isUnit(persistenceUnit)) {\n koqItem.persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n }\n\n if (InvertedUnit.isInvertedUnit(persistenceUnit)) {\n koqItem.persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n }\n\n if (displayLabel !== undefined) {\n koqItem.setDisplayLabel(displayLabel);\n }\n\n return koqItem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemKey> {\n try {\n const koqItem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createKindOfQuantity.bind(schema), koqProps);\n return koqItem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, koqProps.name!, schemaKey), e);\n }\n }\n\n /**\n *\n * @param koqKey A schemaItemKey of the editing KindOfQuantity.\n * @param format A schemaItemKey of a Format.\n * @param isDefault .is set to false when not explicitly passed.\n */\n public async addPresentationFormat(koqKey: SchemaItemKey, format: SchemaItemKey, isDefault: boolean = false): Promise<void> {\n try {\n const kindOfQuantity = await this.getSchemaItem(koqKey, MutableKindOfQuantity);\n const presentationFormat = await this.getSchemaItem(format, Format);\n kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddPresentationUnit, new SchemaItemId(this.schemaItemType, koqKey), e);\n }\n }\n\n public async addPresentationOverrideFormat(koqKey: SchemaItemKey, overrideFormat: OverrideFormat, isDefault: boolean = false): Promise<void> {\n try {\n const kindOfQuantity = await this.getSchemaItem(koqKey, MutableKindOfQuantity);\n kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddPresentationOverride, new SchemaItemId(this.schemaItemType, koqKey), e);\n }\n }\n\n /**\n * @param parent A SchemaItemKey of the parent Format.\n * @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.\n */\n public async createFormatOverride(parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat> {\n try {\n const parentFormat = await this.getSchemaItem(parent, Format);\n return new OverrideFormat(parentFormat, precision, unitLabelOverrides);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateFormatOverride, new SchemaItemId(this.schemaItemType, parent), e);\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
|
-
import { MixinProps, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
|
|
4
|
+
import { Mixin, MixinProps, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
|
|
5
5
|
import { SchemaContextEditor } from "./Editor";
|
|
6
6
|
import { ECClasses } from "./ECClasses";
|
|
7
7
|
import { NavigationProperties } from "./Properties";
|
|
@@ -10,6 +10,7 @@ import { NavigationProperties } from "./Properties";
|
|
|
10
10
|
* A class extending ECClasses allowing you to create schema items of type Mixin.
|
|
11
11
|
*/
|
|
12
12
|
export declare class Mixins extends ECClasses {
|
|
13
|
+
protected get itemTypeClass(): typeof Mixin;
|
|
13
14
|
constructor(schemaEditor: SchemaContextEditor);
|
|
14
15
|
/**
|
|
15
16
|
* Allows access for editing of NavigationProperty attributes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mixins.d.ts","sourceRoot":"","sources":["../../../src/Editing/Mixins.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"Mixins.d.ts","sourceRoot":"","sources":["../../../src/Editing/Mixins.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACiC,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,iBAAiB,EACnG,aAAa,EAAkB,SAAS,EAAE,iBAAiB,EAC5D,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD;;;GAGG;AACH,qBAAa,MAAO,SAAQ,SAAS;IACnC,cAAuB,aAAa,IAAI,OAAO,KAAK,CAEnD;gBAEkB,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,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAe9J;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IASrF,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1E,wBAAwB,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5K;;;;OAIG;IACU,iCAAiC,CAAC,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;CASjI"}
|
|
@@ -10,6 +10,7 @@ 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 MutableMixin_1 = require("./Mutable/MutableMixin");
|
|
13
14
|
const Properties_1 = require("./Properties");
|
|
14
15
|
const Exception_1 = require("./Exception");
|
|
15
16
|
/**
|
|
@@ -17,6 +18,9 @@ const Exception_1 = require("./Exception");
|
|
|
17
18
|
* A class extending ECClasses allowing you to create schema items of type Mixin.
|
|
18
19
|
*/
|
|
19
20
|
class Mixins extends ECClasses_1.ECClasses {
|
|
21
|
+
get itemTypeClass() {
|
|
22
|
+
return ecschema_metadata_1.Mixin;
|
|
23
|
+
}
|
|
20
24
|
constructor(schemaEditor) {
|
|
21
25
|
super(ecschema_metadata_1.SchemaItemType.Mixin, schemaEditor);
|
|
22
26
|
}
|
|
@@ -27,7 +31,7 @@ class Mixins extends ECClasses_1.ECClasses {
|
|
|
27
31
|
async create(schemaKey, name, appliesTo, displayLabel, baseClassKey) {
|
|
28
32
|
try {
|
|
29
33
|
const newClass = await this.createClass(schemaKey, this.schemaItemType, (schema) => schema.createMixinClass.bind(schema), name, baseClassKey);
|
|
30
|
-
const newAppliesTo = await this.getSchemaItem(appliesTo, ecschema_metadata_1.
|
|
34
|
+
const newAppliesTo = await this.getSchemaItem(appliesTo, ecschema_metadata_1.EntityClass);
|
|
31
35
|
newClass.setAppliesTo(new ecschema_metadata_1.DelayedPromiseWithProps(newAppliesTo.key, async () => newAppliesTo));
|
|
32
36
|
if (displayLabel)
|
|
33
37
|
newClass.setDisplayLabel(displayLabel);
|
|
@@ -53,8 +57,8 @@ class Mixins extends ECClasses_1.ECClasses {
|
|
|
53
57
|
}
|
|
54
58
|
async addMixin(entityKey, mixinKey) {
|
|
55
59
|
try {
|
|
56
|
-
const entity = await this.getSchemaItem(entityKey, ecschema_metadata_1.
|
|
57
|
-
const mixin = await this.getSchemaItem(mixinKey);
|
|
60
|
+
const entity = await this.getSchemaItem(entityKey, ecschema_metadata_1.EntityClass);
|
|
61
|
+
const mixin = await this.getSchemaItem(mixinKey, ecschema_metadata_1.Mixin);
|
|
58
62
|
entity.addMixin(mixin);
|
|
59
63
|
}
|
|
60
64
|
catch (e) {
|
|
@@ -63,7 +67,7 @@ class Mixins extends ECClasses_1.ECClasses {
|
|
|
63
67
|
}
|
|
64
68
|
async createNavigationProperty(mixinKey, name, relationship, direction) {
|
|
65
69
|
try {
|
|
66
|
-
const mixin = await this.getSchemaItem(mixinKey);
|
|
70
|
+
const mixin = await this.getSchemaItem(mixinKey, MutableMixin_1.MutableMixin);
|
|
67
71
|
await mixin.createNavigationProperty(name, relationship, direction);
|
|
68
72
|
}
|
|
69
73
|
catch (e) {
|
|
@@ -77,7 +81,7 @@ class Mixins extends ECClasses_1.ECClasses {
|
|
|
77
81
|
*/
|
|
78
82
|
async createNavigationPropertyFromProps(classKey, navigationProps) {
|
|
79
83
|
try {
|
|
80
|
-
const mixin = await this.getSchemaItem(classKey);
|
|
84
|
+
const mixin = await this.getSchemaItem(classKey, MutableMixin_1.MutableMixin);
|
|
81
85
|
const property = await mixin.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);
|
|
82
86
|
await property.fromJSON(navigationProps);
|
|
83
87
|
}
|