@itwin/ecschema-editing 5.0.0-dev.99 → 5.1.0-dev.1

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 (108) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/Differencing/SchemaDifferenceValidator.js +1 -1
  3. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  4. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  5. package/lib/cjs/Editing/Editor.js +1 -1
  6. package/lib/cjs/Editing/Editor.js.map +1 -1
  7. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  8. package/lib/cjs/Editing/Formats.js +7 -2
  9. package/lib/cjs/Editing/Formats.js.map +1 -1
  10. package/lib/cjs/Editing/KindOfQuantities.d.ts +2 -2
  11. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  12. package/lib/cjs/Editing/KindOfQuantities.js +3 -3
  13. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  14. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +3 -3
  15. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts.map +1 -1
  16. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  17. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +4 -4
  18. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
  19. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  20. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +7 -7
  21. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -1
  22. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  23. package/lib/cjs/Editing/Properties.js +6 -6
  24. package/lib/cjs/Editing/Properties.js.map +1 -1
  25. package/lib/cjs/Editing/RelationshipClasses.js +12 -12
  26. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  27. package/lib/cjs/Editing/SchemaItems.d.ts +1 -1
  28. package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
  29. package/lib/cjs/Editing/SchemaItems.js +3 -3
  30. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  31. package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
  32. package/lib/cjs/Merging/ConstantMerger.js +3 -3
  33. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  34. package/lib/cjs/Merging/FormatMerger.d.ts.map +1 -1
  35. package/lib/cjs/Merging/FormatMerger.js +6 -4
  36. package/lib/cjs/Merging/FormatMerger.js.map +1 -1
  37. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  38. package/lib/cjs/Merging/KindOfQuantityMerger.js +4 -1
  39. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  40. package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
  41. package/lib/cjs/Merging/PhenomenonMerger.js +1 -1
  42. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  43. package/lib/cjs/Merging/RelationshipClassMerger.js +1 -1
  44. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  45. package/lib/cjs/Merging/Utils.d.ts.map +1 -1
  46. package/lib/cjs/Merging/Utils.js +1 -1
  47. package/lib/cjs/Merging/Utils.js.map +1 -1
  48. package/lib/cjs/Validation/ECRules.js +4 -4
  49. package/lib/cjs/Validation/ECRules.js.map +1 -1
  50. package/lib/cjs/Validation/SchemaChanges.js +2 -2
  51. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  52. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  53. package/lib/cjs/Validation/SchemaComparer.js +19 -8
  54. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  55. package/lib/esm/Differencing/SchemaDifferenceValidator.js +1 -1
  56. package/lib/esm/Differencing/SchemaDifferenceValidator.js.map +1 -1
  57. package/lib/esm/Editing/Editor.d.ts.map +1 -1
  58. package/lib/esm/Editing/Editor.js +2 -2
  59. package/lib/esm/Editing/Editor.js.map +1 -1
  60. package/lib/esm/Editing/Formats.d.ts.map +1 -1
  61. package/lib/esm/Editing/Formats.js +8 -3
  62. package/lib/esm/Editing/Formats.js.map +1 -1
  63. package/lib/esm/Editing/KindOfQuantities.d.ts +2 -2
  64. package/lib/esm/Editing/KindOfQuantities.d.ts.map +1 -1
  65. package/lib/esm/Editing/KindOfQuantities.js +3 -3
  66. package/lib/esm/Editing/KindOfQuantities.js.map +1 -1
  67. package/lib/esm/Editing/Mutable/MutableFormat.d.ts +3 -3
  68. package/lib/esm/Editing/Mutable/MutableFormat.d.ts.map +1 -1
  69. package/lib/esm/Editing/Mutable/MutableFormat.js.map +1 -1
  70. package/lib/esm/Editing/Mutable/MutableKindOfQuantity.d.ts +4 -4
  71. package/lib/esm/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
  72. package/lib/esm/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  73. package/lib/esm/Editing/Mutable/MutableRelationshipClass.d.ts +7 -7
  74. package/lib/esm/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -1
  75. package/lib/esm/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  76. package/lib/esm/Editing/Properties.js +6 -6
  77. package/lib/esm/Editing/Properties.js.map +1 -1
  78. package/lib/esm/Editing/RelationshipClasses.js +12 -12
  79. package/lib/esm/Editing/RelationshipClasses.js.map +1 -1
  80. package/lib/esm/Editing/SchemaItems.d.ts +1 -1
  81. package/lib/esm/Editing/SchemaItems.d.ts.map +1 -1
  82. package/lib/esm/Editing/SchemaItems.js +4 -4
  83. package/lib/esm/Editing/SchemaItems.js.map +1 -1
  84. package/lib/esm/Merging/ConstantMerger.d.ts.map +1 -1
  85. package/lib/esm/Merging/ConstantMerger.js +4 -4
  86. package/lib/esm/Merging/ConstantMerger.js.map +1 -1
  87. package/lib/esm/Merging/FormatMerger.d.ts.map +1 -1
  88. package/lib/esm/Merging/FormatMerger.js +7 -5
  89. package/lib/esm/Merging/FormatMerger.js.map +1 -1
  90. package/lib/esm/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  91. package/lib/esm/Merging/KindOfQuantityMerger.js +5 -2
  92. package/lib/esm/Merging/KindOfQuantityMerger.js.map +1 -1
  93. package/lib/esm/Merging/PhenomenonMerger.d.ts.map +1 -1
  94. package/lib/esm/Merging/PhenomenonMerger.js +2 -2
  95. package/lib/esm/Merging/PhenomenonMerger.js.map +1 -1
  96. package/lib/esm/Merging/RelationshipClassMerger.js +1 -1
  97. package/lib/esm/Merging/RelationshipClassMerger.js.map +1 -1
  98. package/lib/esm/Merging/Utils.d.ts.map +1 -1
  99. package/lib/esm/Merging/Utils.js +2 -2
  100. package/lib/esm/Merging/Utils.js.map +1 -1
  101. package/lib/esm/Validation/ECRules.js +4 -4
  102. package/lib/esm/Validation/ECRules.js.map +1 -1
  103. package/lib/esm/Validation/SchemaChanges.js +3 -3
  104. package/lib/esm/Validation/SchemaChanges.js.map +1 -1
  105. package/lib/esm/Validation/SchemaComparer.d.ts.map +1 -1
  106. package/lib/esm/Validation/SchemaComparer.js +19 -8
  107. package/lib/esm/Validation/SchemaComparer.js.map +1 -1
  108. package/package.json +9 -9
@@ -6,7 +6,7 @@
6
6
  * @module Editing
7
7
  */
8
8
  import * as Rules from "../Validation/ECRules";
9
- import { ECObjectsError, ECObjectsStatus, isSupportedSchemaItemType, Schema, SchemaItemType, SchemaMatchType } from "@itwin/ecschema-metadata";
9
+ import { ECSchemaError, ECSchemaStatus, isSupportedSchemaItemType, Schema, SchemaItemType, SchemaMatchType } from "@itwin/ecschema-metadata";
10
10
  import { assert } from "@itwin/core-bentley";
11
11
  import { Constants } from "./Constants";
12
12
  import { CustomAttributes } from "./CustomAttributes";
@@ -251,7 +251,7 @@ export class SchemaContextEditor {
251
251
  schema.setAlias(alias);
252
252
  }
253
253
  catch (e) {
254
- if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.InvalidECName) {
254
+ if (e instanceof ECSchemaError && e.errorNumber === ECSchemaStatus.InvalidECName) {
255
255
  throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), new SchemaEditingError(ECEditingStatus.InvalidSchemaAlias, new SchemaId(schemaKey)));
256
256
  }
257
257
  throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), e);
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/Editing/Editor.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAmB,cAAc,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,EAA4C,cAAc,EAAa,eAAe,EAA2B,MAAM,0BAA0B,CAAC;AAE9O,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,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AC;YACf,IAAI,CAAC,YAAY,cAAc,IAAI,CAAC,CAAC,WAAW,KAAK,eAAe,CAAC,aAAa,EAAE,CAAC;gBACnF,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,cAAc,EAAE,IAAI,QAAQ,CAAC,SAAS,CAAC,EAClF,IAAI,kBAAkB,CAAC,eAAe,CAAC,kBAAkB,EAAE,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACzF,CAAC;YAED,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,cAAc,EAAG,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,IAA6B;IACrD,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAsB,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport * as Rules from \"../Validation/ECRules\";\nimport { CustomAttribute, ECObjectsError, ECObjectsStatus, isSupportedSchemaItemType, Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, SchemaMatchType, SupportedSchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Constants } from \"./Constants\";\nimport { CustomAttributes } from \"./CustomAttributes\";\nimport { Entities } from \"./Entities\";\nimport { Enumerations } from \"./Enumerations\";\nimport { Formats } from \"./Formats\";\nimport { InvertedUnits } from \"./InvertedUnits\";\nimport { KindOfQuantities } from \"./KindOfQuantities\";\nimport { Mixins } from \"./Mixins\";\nimport { Phenomena } from \"./Phenomena\";\nimport { PropertyCategories } from \"./PropertyCategories\";\nimport { RelationshipClasses } from \"./RelationshipClasses\";\nimport { Structs } from \"./Structs\";\nimport { Units } from \"./Units\";\nimport { UnitSystems } from \"./UnitSystems\";\nimport { CustomAttributeId, ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\n\n/**\n * A class that allows you to edit and create schemas, classes, and items from the SchemaContext level.\n * @alpha\n */\nexport class SchemaContextEditor {\n private _schemaContext: SchemaContext;\n public readonly entities = new Entities(this);\n public readonly mixins = new Mixins(this);\n public readonly structs = new Structs(this);\n public readonly customAttributes = new CustomAttributes(this);\n public readonly relationships = new RelationshipClasses(this);\n public readonly constants = new Constants(this);\n public readonly enumerations = new Enumerations(this);\n public readonly formats = new Formats(this);\n public readonly kindOfQuantities = new KindOfQuantities(this);\n public readonly units = new Units(this);\n public readonly phenomenons = new Phenomena(this);\n public readonly unitSystems = new UnitSystems(this);\n public readonly propertyCategories = new PropertyCategories(this);\n public readonly invertedUnits = new InvertedUnits(this);\n\n /**\n * Creates a new SchemaContextEditor instance.\n * @param schemaContext The SchemaContext the Editor will use to edit in.\n */\n constructor(schemaContext: SchemaContext) {\n // TODO: Make copy\n this._schemaContext = schemaContext;\n }\n\n /** Allows you to get schema classes and items through regular SchemaContext methods. */\n public get schemaContext(): SchemaContext {\n return this._schemaContext;\n }\n\n public async finish(): Promise<SchemaContext> {\n return this._schemaContext;\n }\n\n /**\n * Helper method for retrieving a schema, previously added, from the SchemaContext.\n * @param schemaKey The SchemaKey identifying the schema.\n * @internal\n */\n public async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\n const schema = await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema as MutableSchema;\n }\n\n /**\n * Creates a Schema with the given properties and adds it to the current schema context.\n * @param name The name given to the new schema.\n * @param alias The alias of the new schema.\n * @param readVersion The read version number of the schema.\n * @param writeVersion The write version number of the schema.\n * @param minorVersion The minor version number of the schema.\n * @returns Resolves to the SchemaKey of created schema.\n */\n public async createSchema(name: string, alias: string, readVersion: number, writeVersion: number, minorVersion: number): Promise<SchemaKey> {\n const newSchema = new Schema(this._schemaContext, name, alias, readVersion, writeVersion, minorVersion);\n await this._schemaContext.addSchema(newSchema);\n return newSchema.schemaKey;\n }\n\n /**\n * Adds a referenced schema to the schema identified by the given SchemaKey.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param refSchema The referenced schema to add.\n */\n public async addSchemaReference(schemaKey: SchemaKey, refSchema: Schema): Promise<void> {\n try {\n const schema = await this.lookupSchema(schemaKey, SchemaMatchType.Exact);\n await schema.addReference(refSchema);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of Rules.validateSchemaReferences(schema)) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeReference(schema, refSchema);\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new SchemaId(schemaKey), undefined, diagnostics);\n }\n\n if (!await this.schemaContext.getCachedSchema(refSchema.schemaKey)) {\n await this.schemaContext.addSchema(refSchema);\n }\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddSchemaReference, new SchemaId(schemaKey), e);\n }\n }\n\n /**\n * Adds a CustomAttribute instance to the schema identified by the given SchemaKey\n * @param schemaKey The SchemaKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(schemaKey: SchemaKey, customAttribute: CustomAttribute): Promise<void> {\n try {\n const schema = await this.lookupSchema(schemaKey);\n schema.addCustomAttribute(customAttribute);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of Rules.validateCustomAttributeInstance(schema, customAttribute)) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeCustomAttribute(schema, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, schema), undefined, diagnostics);\n }\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToClass, new SchemaId(schemaKey), e);\n }\n }\n\n /**\n * Sets the schema version.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param readVersion The read version of the schema. If not specified, the existing read version will be maintained.\n * @param writeVersion The write version of the schema. If not specified, the existing write version will be maintained.\n * @param minorVersion The minor version of the schema. If not specified, the existing minor version will be maintained.\n * @returns Resolves to the new SchemaKey containing version updates.\n */\n public async setVersion(schemaKey: SchemaKey, readVersion?: number, writeVersion?: number, minorVersion?: number): Promise<SchemaKey> {\n try {\n const schema = await this.lookupSchema(schemaKey);\n schema.setVersion(readVersion || schema.readVersion, writeVersion || schema.writeVersion, minorVersion || schema.minorVersion);\n\n return schema.schemaKey;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetSchemaVersion, new SchemaId(schemaKey), e);\n }\n }\n\n /**\n * Increments the minor version of a schema.\n * @param schemaKey The SchemaKey identifying the schema.\n * @returns Resolves to the new SchemaKey containing version updates.\n */\n public async incrementMinorVersion(schemaKey: SchemaKey): Promise<SchemaKey> {\n try {\n const schema = await this.lookupSchema(schemaKey);\n schema.setVersion(schema.readVersion, schema.writeVersion, schema.minorVersion + 1);\n\n return schema.schemaKey;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.IncrementSchemaMinorVersion, new SchemaId(schemaKey), e);\n }\n }\n\n /** @internal */\n public async lookupSchemaItem(schemaOrKey: Schema | SchemaKey, schemaItemKey: SchemaItemKey, schemaItemType: SchemaItemType): Promise<SchemaItem> {\n if(Schema.isSchema(schemaOrKey)) {\n schemaOrKey = schemaOrKey.schemaKey;\n }\n\n const schemaItem = await this.schemaContext.getSchemaItem(schemaItemKey);\n if (schemaItem === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(schemaItemType, schemaItemKey));\n\n if (schemaItemType !== schemaItem.schemaItemType)\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType, schemaItemKey));\n\n return schemaItem;\n }\n\n /** @internal */\n public async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T>> {\n const schemaItem = await this.schemaContext.getSchemaItem(schemaItemKey);\n const schemaItemType = itemConstructor.schemaItemType;\n if(!isSchemaItemType(schemaItemType)) {\n // This block should never be hit, as the editor components always pass in the itemConstructor with a valid schemaItemType.\n throw new Error(`Invalid schema item lookup for: ${schemaItemType}`);\n }\n\n if (!schemaItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFoundInContext, new SchemaItemId(schemaItemType, schemaItemKey));\n }\n\n if (!isSupportedSchemaItemType(schemaItem.schemaItemType, itemConstructor.schemaItemType))\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType, schemaItemKey));\n\n return schemaItem as InstanceType<T>;\n }\n\n private removeReference(schema: Schema, refSchema: Schema) {\n const index: number = schema.references.indexOf(refSchema);\n if (index !== -1) {\n schema.references.splice(index, 1);\n }\n }\n\n private removeCustomAttribute(schema: Schema, customAttribute: CustomAttribute) {\n assert(schema.customAttributes !== undefined);\n const map = schema.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n\n private async lookupSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<MutableSchema> {\n const schema = await this.schemaContext.getCachedSchema(schemaKey, matchType);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema as MutableSchema;\n }\n\n /**\n * Sets the Schemas description.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param description The new description to set.\n */\n public async setDescription(schemaKey: SchemaKey, description: string) {\n const schema = await this.lookupSchema(schemaKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaId(schemaKey), e);\n });\n schema.setDescription(description);\n }\n\n /**\n * Sets the Schemas display label.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param label The new label to set.\n */\n public async setDisplayLabel(schemaKey: SchemaKey, label: string) {\n const schema = await this.lookupSchema(schemaKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaId(schemaKey), e);\n });\n schema.setDisplayLabel(label);\n }\n\n /**\n * Sets the Schemas alias.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param alias The new alias to set.\n */\n public async setAlias(schemaKey: SchemaKey, alias: string) {\n const schema = await this.lookupSchema(schemaKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), e);\n });\n\n try {\n for (const currentSchema of this.schemaContext.getKnownSchemas()) {\n if (currentSchema.schemaKey.matches(schemaKey))\n continue;\n\n if (currentSchema.alias.toLowerCase() === alias.toLowerCase())\n throw new SchemaEditingError(ECEditingStatus.SchemaAliasAlreadyExists, new SchemaId(schemaKey), undefined, undefined, `Schema ${currentSchema.name} already uses the alias '${alias}'.`);\n }\n schema.setAlias(alias);\n } catch(e: any) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.InvalidECName) {\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey),\n new SchemaEditingError(ECEditingStatus.InvalidSchemaAlias, new SchemaId(schemaKey)));\n }\n\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), e);\n }\n }\n}\n\nfunction isSchemaItemType(type: SupportedSchemaItemType): type is SchemaItemType {\n return Object.values(SchemaItemType).includes(type as SchemaItemType);\n}"]}
1
+ {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/Editing/Editor.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAmB,aAAa,EAAE,cAAc,EAAE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AAC,IAA6B;IACrD,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAsB,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport * as Rules from \"../Validation/ECRules\";\nimport { CustomAttribute, ECSchemaError, ECSchemaStatus, isSupportedSchemaItemType, Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, SchemaMatchType, SupportedSchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Constants } from \"./Constants\";\nimport { CustomAttributes } from \"./CustomAttributes\";\nimport { Entities } from \"./Entities\";\nimport { Enumerations } from \"./Enumerations\";\nimport { Formats } from \"./Formats\";\nimport { InvertedUnits } from \"./InvertedUnits\";\nimport { KindOfQuantities } from \"./KindOfQuantities\";\nimport { Mixins } from \"./Mixins\";\nimport { Phenomena } from \"./Phenomena\";\nimport { PropertyCategories } from \"./PropertyCategories\";\nimport { RelationshipClasses } from \"./RelationshipClasses\";\nimport { Structs } from \"./Structs\";\nimport { Units } from \"./Units\";\nimport { UnitSystems } from \"./UnitSystems\";\nimport { CustomAttributeId, ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\n\n/**\n * A class that allows you to edit and create schemas, classes, and items from the SchemaContext level.\n * @alpha\n */\nexport class SchemaContextEditor {\n private _schemaContext: SchemaContext;\n public readonly entities = new Entities(this);\n public readonly mixins = new Mixins(this);\n public readonly structs = new Structs(this);\n public readonly customAttributes = new CustomAttributes(this);\n public readonly relationships = new RelationshipClasses(this);\n public readonly constants = new Constants(this);\n public readonly enumerations = new Enumerations(this);\n public readonly formats = new Formats(this);\n public readonly kindOfQuantities = new KindOfQuantities(this);\n public readonly units = new Units(this);\n public readonly phenomenons = new Phenomena(this);\n public readonly unitSystems = new UnitSystems(this);\n public readonly propertyCategories = new PropertyCategories(this);\n public readonly invertedUnits = new InvertedUnits(this);\n\n /**\n * Creates a new SchemaContextEditor instance.\n * @param schemaContext The SchemaContext the Editor will use to edit in.\n */\n constructor(schemaContext: SchemaContext) {\n // TODO: Make copy\n this._schemaContext = schemaContext;\n }\n\n /** Allows you to get schema classes and items through regular SchemaContext methods. */\n public get schemaContext(): SchemaContext {\n return this._schemaContext;\n }\n\n public async finish(): Promise<SchemaContext> {\n return this._schemaContext;\n }\n\n /**\n * Helper method for retrieving a schema, previously added, from the SchemaContext.\n * @param schemaKey The SchemaKey identifying the schema.\n * @internal\n */\n public async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\n const schema = await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema as MutableSchema;\n }\n\n /**\n * Creates a Schema with the given properties and adds it to the current schema context.\n * @param name The name given to the new schema.\n * @param alias The alias of the new schema.\n * @param readVersion The read version number of the schema.\n * @param writeVersion The write version number of the schema.\n * @param minorVersion The minor version number of the schema.\n * @returns Resolves to the SchemaKey of created schema.\n */\n public async createSchema(name: string, alias: string, readVersion: number, writeVersion: number, minorVersion: number): Promise<SchemaKey> {\n const newSchema = new Schema(this._schemaContext, name, alias, readVersion, writeVersion, minorVersion);\n await this._schemaContext.addSchema(newSchema);\n return newSchema.schemaKey;\n }\n\n /**\n * Adds a referenced schema to the schema identified by the given SchemaKey.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param refSchema The referenced schema to add.\n */\n public async addSchemaReference(schemaKey: SchemaKey, refSchema: Schema): Promise<void> {\n try {\n const schema = await this.lookupSchema(schemaKey, SchemaMatchType.Exact);\n await schema.addReference(refSchema);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of Rules.validateSchemaReferences(schema)) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeReference(schema, refSchema);\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new SchemaId(schemaKey), undefined, diagnostics);\n }\n\n if (!await this.schemaContext.getCachedSchema(refSchema.schemaKey)) {\n await this.schemaContext.addSchema(refSchema);\n }\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddSchemaReference, new SchemaId(schemaKey), e);\n }\n }\n\n /**\n * Adds a CustomAttribute instance to the schema identified by the given SchemaKey\n * @param schemaKey The SchemaKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(schemaKey: SchemaKey, customAttribute: CustomAttribute): Promise<void> {\n try {\n const schema = await this.lookupSchema(schemaKey);\n schema.addCustomAttribute(customAttribute);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of Rules.validateCustomAttributeInstance(schema, customAttribute)) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeCustomAttribute(schema, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, schema), undefined, diagnostics);\n }\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToClass, new SchemaId(schemaKey), e);\n }\n }\n\n /**\n * Sets the schema version.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param readVersion The read version of the schema. If not specified, the existing read version will be maintained.\n * @param writeVersion The write version of the schema. If not specified, the existing write version will be maintained.\n * @param minorVersion The minor version of the schema. If not specified, the existing minor version will be maintained.\n * @returns Resolves to the new SchemaKey containing version updates.\n */\n public async setVersion(schemaKey: SchemaKey, readVersion?: number, writeVersion?: number, minorVersion?: number): Promise<SchemaKey> {\n try {\n const schema = await this.lookupSchema(schemaKey);\n schema.setVersion(readVersion || schema.readVersion, writeVersion || schema.writeVersion, minorVersion || schema.minorVersion);\n\n return schema.schemaKey;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetSchemaVersion, new SchemaId(schemaKey), e);\n }\n }\n\n /**\n * Increments the minor version of a schema.\n * @param schemaKey The SchemaKey identifying the schema.\n * @returns Resolves to the new SchemaKey containing version updates.\n */\n public async incrementMinorVersion(schemaKey: SchemaKey): Promise<SchemaKey> {\n try {\n const schema = await this.lookupSchema(schemaKey);\n schema.setVersion(schema.readVersion, schema.writeVersion, schema.minorVersion + 1);\n\n return schema.schemaKey;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.IncrementSchemaMinorVersion, new SchemaId(schemaKey), e);\n }\n }\n\n /** @internal */\n public async lookupSchemaItem(schemaOrKey: Schema | SchemaKey, schemaItemKey: SchemaItemKey, schemaItemType: SchemaItemType): Promise<SchemaItem> {\n if(Schema.isSchema(schemaOrKey)) {\n schemaOrKey = schemaOrKey.schemaKey;\n }\n\n const schemaItem = await this.schemaContext.getSchemaItem(schemaItemKey);\n if (schemaItem === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(schemaItemType, schemaItemKey));\n\n if (schemaItemType !== schemaItem.schemaItemType)\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType, schemaItemKey));\n\n return schemaItem;\n }\n\n /** @internal */\n public async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T>> {\n const schemaItem = await this.schemaContext.getSchemaItem(schemaItemKey);\n const schemaItemType = itemConstructor.schemaItemType;\n if(!isSchemaItemType(schemaItemType)) {\n // This block should never be hit, as the editor components always pass in the itemConstructor with a valid schemaItemType.\n throw new Error(`Invalid schema item lookup for: ${schemaItemType}`);\n }\n\n if (!schemaItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFoundInContext, new SchemaItemId(schemaItemType, schemaItemKey));\n }\n\n if (!isSupportedSchemaItemType(schemaItem.schemaItemType, itemConstructor.schemaItemType))\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType, schemaItemKey));\n\n return schemaItem as InstanceType<T>;\n }\n\n private removeReference(schema: Schema, refSchema: Schema) {\n const index: number = schema.references.indexOf(refSchema);\n if (index !== -1) {\n schema.references.splice(index, 1);\n }\n }\n\n private removeCustomAttribute(schema: Schema, customAttribute: CustomAttribute) {\n assert(schema.customAttributes !== undefined);\n const map = schema.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n\n private async lookupSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<MutableSchema> {\n const schema = await this.schemaContext.getCachedSchema(schemaKey, matchType);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema as MutableSchema;\n }\n\n /**\n * Sets the Schemas description.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param description The new description to set.\n */\n public async setDescription(schemaKey: SchemaKey, description: string) {\n const schema = await this.lookupSchema(schemaKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaId(schemaKey), e);\n });\n schema.setDescription(description);\n }\n\n /**\n * Sets the Schemas display label.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param label The new label to set.\n */\n public async setDisplayLabel(schemaKey: SchemaKey, label: string) {\n const schema = await this.lookupSchema(schemaKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaId(schemaKey), e);\n });\n schema.setDisplayLabel(label);\n }\n\n /**\n * Sets the Schemas alias.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param alias The new alias to set.\n */\n public async setAlias(schemaKey: SchemaKey, alias: string) {\n const schema = await this.lookupSchema(schemaKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), e);\n });\n\n try {\n for (const currentSchema of this.schemaContext.getKnownSchemas()) {\n if (currentSchema.schemaKey.matches(schemaKey))\n continue;\n\n if (currentSchema.alias.toLowerCase() === alias.toLowerCase())\n throw new SchemaEditingError(ECEditingStatus.SchemaAliasAlreadyExists, new SchemaId(schemaKey), undefined, undefined, `Schema ${currentSchema.name} already uses the alias '${alias}'.`);\n }\n schema.setAlias(alias);\n } catch(e: any) {\n if (e instanceof ECSchemaError && e.errorNumber === ECSchemaStatus.InvalidECName) {\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey),\n new SchemaEditingError(ECEditingStatus.InvalidSchemaAlias, new SchemaId(schemaKey)));\n }\n\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), e);\n }\n }\n}\n\nfunction isSchemaItemType(type: SupportedSchemaItemType): type is SchemaItemType {\n return Object.values(SchemaItemType).includes(type as SchemaItemType);\n}"]}
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"Formats.d.ts","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA2B,MAAM,EAAgB,qBAAqB,EAAE,aAAa,EAAkB,SAAS,EAAQ,MAAM,0BAA0B,CAAC;AAChK,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;IAgCvJ;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ/G"}
@@ -5,7 +5,7 @@
5
5
  /** @packageDocumentation
6
6
  * @module Editing
7
7
  */
8
- import { Format, InvertedUnit, SchemaItemType, Unit } from "@itwin/ecschema-metadata";
8
+ import { DelayedPromiseWithProps, Format, InvertedUnit, SchemaItemType, Unit } from "@itwin/ecschema-metadata";
9
9
  import { ECEditingStatus, SchemaEditingError, SchemaItemId } from "./Exception";
10
10
  import { SchemaItems } from "./SchemaItems";
11
11
  /**
@@ -28,10 +28,15 @@ export class Formats extends SchemaItems {
28
28
  if (!unitItem) {
29
29
  throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFoundInContext, new SchemaItemId(SchemaItemType.Unit, unit));
30
30
  }
31
- if (!Unit.isUnit(unitItem) && !InvertedUnit.isInvertedUnit(unitItem)) {
31
+ if (Unit.isUnit(unitItem)) {
32
+ newFormat.addUnit(new DelayedPromiseWithProps(unitItem.key, async () => unitItem));
33
+ }
34
+ else if (InvertedUnit.isInvertedUnit(unitItem)) {
35
+ newFormat.addUnit(new DelayedPromiseWithProps(unitItem.key, async () => unitItem));
36
+ }
37
+ else {
32
38
  throw new SchemaEditingError(ECEditingStatus.InvalidFormatUnitsSpecified, new SchemaItemId(unitItem.schemaItemType, unitItem.key));
33
39
  }
34
- newFormat.addUnit(unitItem);
35
40
  }
36
41
  }
37
42
  if (displayLabel)
@@ -1 +1 @@
1
- {"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAwC,cAAc,EAAa,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIvI,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,OAAQ,SAAQ,WAAW;IACtC,IAAuB,aAAa;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,cAAc,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,M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nF,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,kBAAkB,CAAC,eAAe,CAAC,yBAAyB,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClJ,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module 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
+ {"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,YAAY,EAAwC,cAAc,EAAa,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIhK,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW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G,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACrF,CAAC;yBAAM,CAAC;wBACN,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,2BAA2B,EAAE,IAAI,YAAY,CAAC,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;oBACrI,CAAC;gBACH,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,kBAAkB,CAAC,eAAe,CAAC,sBAAsB,EAAE,IAAI,YAAY,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,kBAAkB,CAAC,eAAe,CAAC,yBAAyB,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClJ,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, 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) ) {\n newFormat.addUnit(new DelayedPromiseWithProps(unitItem.key, async () => unitItem));\n } else if (InvertedUnit.isInvertedUnit(unitItem) ) {\n newFormat.addUnit(new DelayedPromiseWithProps(unitItem.key, async () => unitItem));\n } else {\n throw new SchemaEditingError(ECEditingStatus.InvalidFormatUnitsSpecified, new SchemaItemId(unitItem.schemaItemType, unitItem.key));\n }\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 { InvertedUnit, KindOfQuantity, KindOfQuantityProps, OverrideFormat, SchemaItemKey, SchemaKey, Unit } from "@itwin/ecschema-metadata";
4
+ import { KindOfQuantity, KindOfQuantityProps, LazyLoadedInvertedUnit, LazyLoadedUnit, OverrideFormat, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
5
5
  import { SchemaContextEditor } from "./Editor";
6
6
  import { SchemaItems } from "./SchemaItems";
7
7
  /**
@@ -25,6 +25,6 @@ export declare class KindOfQuantities extends SchemaItems {
25
25
  * @param parent A SchemaItemKey of the parent Format.
26
26
  * @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.
27
27
  */
28
- createFormatOverride(parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat>;
28
+ createFormatOverride(parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): Promise<OverrideFormat>;
29
29
  }
30
30
  //# sourceMappingUR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d.ts","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAEiB,cAAc,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EACjH,aAAa,EAAkB,SAAS,EACzC,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,cAAc,GAAG,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;CAQjM"}
@@ -27,10 +27,10 @@ export class KindOfQuantities extends SchemaItems {
27
27
  if (persistenceUnit === undefined || (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit)))
28
28
  throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(SchemaItemType.Unit, persistenceUnitKey));
29
29
  if (Unit.isUnit(persistenceUnit)) {
30
- koqItem.persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
30
+ koqItem.setPersistenceUnit(new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit));
31
31
  }
32
32
  if (InvertedUnit.isInvertedUnit(persistenceUnit)) {
33
- koqItem.persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
33
+ koqItem.setPersistenceUnit(new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit));
34
34
  }
35
35
  if (displayLabel !== undefined) {
36
36
  koqItem.setDisplayLabel(displayLabel);
@@ -60,7 +60,7 @@ export class KindOfQuantities extends SchemaItems {
60
60
  try {
61
61
  const kindOfQuantity = await this.getSchemaItem(koqKey, MutableKindOfQuantity);
62
62
  const presentationFormat = await this.getSchemaItem(format, Format);
63
- kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);
63
+ kindOfQuantity.addPresentationFormat(new DelayedPromiseWithProps(presentationFormat.key, async () => presentationFormat), isDefault);
64
64
  }
65
65
  catch (e) {
66
66
  throw new SchemaEditingError(ECEditingStatus.AddPresentationUnit, new SchemaItemId(this.schemaItemType, koqKey), e);
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantities.js","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACL,uBAAuB,EACvB,MAAM,EAAE,YAAY,EAAE,cAAc,EAAuB,cAAc,EAC1D,cAAc,EAAa,IAAI,GAC/C,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE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,CAAC,CAAC;YACpE,cAAc,CAAC,qBAAqB,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;QACtE,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,mBAAmB,EAAE,IAAI,YAAY,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,qBAAqB,CAAC,CAAC;YAC/E,cAAc,CAAC,qBAAqB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAClE,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,uBAAuB,EAAE,IAAI,YAAY,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,MAAM,CAAC,CAAC;YAC9D,OAAO,IAAI,cAAc,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;QACzE,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,oBAAoB,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACvH,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module 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
+ {"version":3,"file":"KindOfQuantities.js","sourceRoot":"","sources":["../../../src/Editing/KindOfQuantities.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACL,uBAAuB,EACvB,MAAM,EAAE,YAAY,EAAE,cAAc,EAA+D,cAAc,EAClG,cAAc,EAAa,IAAI,GAC/C,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,IAAuB,aAAa;QAClC,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,YAAmB,YAAiC;QAClD,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,kBAAiC,EAAE,YAAqB;QAC9G,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAiB,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAA0B,CAAC;YACjL,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;YAC5E,IAAI,eAAe,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,eA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AAC,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1H,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,oBAAoB,CAAC,MAAqB,EAAE,SAAkB,EAAE,kBAAyF;QACpK,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC9D,OAAO,IAAI,cAAc,CAAC,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;QACzE,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,oBAAoB,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACvH,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n DelayedPromiseWithProps,\n Format, InvertedUnit, KindOfQuantity, KindOfQuantityProps, LazyLoadedInvertedUnit, LazyLoadedUnit, 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.setPersistenceUnit(new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit));\n }\n\n if (InvertedUnit.isInvertedUnit(persistenceUnit)) {\n koqItem.setPersistenceUnit(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(new DelayedPromiseWithProps(presentationFormat.key, async () => 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<[LazyLoadedUnit | LazyLoadedInvertedUnit, 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,11 +1,11 @@
1
- import { Format, InvertedUnit, Unit } from "@itwin/ecschema-metadata";
1
+ import { Format, LazyLoadedInvertedUnit, LazyLoadedUnit } from "@itwin/ecschema-metadata";
2
2
  import { FormatTraits, FormatType, ScientificType, ShowSignOption } from "@itwin/core-quantity";
3
3
  /**
4
4
  * @internal
5
5
  * An abstract class used for schema editing.
6
6
  */
7
7
  export declare abstract class MutableFormat extends Format {
8
- abstract addUnit(unit: Unit | InvertedUnit, label?: string): void;
8
+ abstract addUnit(unit: LazyLoadedUnit | LazyLoadedInvertedUnit, label?: string): void;
9
9
  abstract setPrecision(precision: number): void;
10
10
  abstract setFormatType(formatType: FormatType): void;
11
11
  abstract setRoundFactor(roundFactor: number): void;
@@ -20,7 +20,7 @@ export declare abstract class MutableFormat extends Format {
20
20
  abstract setSpacer(spacer: string): void;
21
21
  abstract setIncludeZero(includeZero: boolean): void;
22
22
  abstract setFormatTraits(formatTraits: FormatTraits): void;
23
- abstract setUnits(units: Array<[Unit | InvertedUnit, string | undefined]>): void;
23
+ abstract setUnits(units: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): void;
24
24
  abstract setDisplayLabel(displayLabel: string): void;
25
25
  }
26
26
  //# sourceMappingURL=MutableFormat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MutableFormat.d.ts","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableFormat.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEhG;;;GAGG;AACH,8BAAsB,aAAc,SAAQ,MAAM;aACvB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,YAAY,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;aACxD,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;aACrC,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;aAC3C,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;aACzC,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI;aACnD,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;aAC5C,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;aAC7C,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;aACxC,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;aAC5C,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAA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W,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;aACnC,oBAAoB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;aACrD,iBAAiB,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI;aACvD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;aAC/B,cAAc,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI;aAC1C,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;aACjD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,cAAc,GAAG,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,IAAI;aAC3F,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"MutableFormat.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableFormat.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAsB,MAAM,0BAA0B,CAAC;AAGtE;;;GAGG;AACH,MAAM,OAAgB,aAAc,SAAQ,MAAM;CAkBjD","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Format, InvertedUnit, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatTraits, FormatType, ScientificType, ShowSignOption } from \"@itwin/core-quantity\";\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableFormat extends Format {\n public abstract override addUnit(unit: Unit | InvertedUnit, label?: string): void;\n public abstract override setPrecision(precision: number): void;\n public abstract override setFormatType(formatType: FormatType): void;\n public abstract override setRoundFactor(roundFactor: number): void;\n public abstract override setShowSignOption(signOption: ShowSignOption): void;\n public abstract override setDecimalSeparator(separator: string): void;\n public abstract override setThousandSeparator(separator: string): void;\n public abstract override setUomSeparator(separator: string): void;\n public abstract override setStationSeparator(separator: string): void;\n public abstract override setMinWidth(minWidth: number): void;\n public abstract override setStationOffsetSize(stationOffsetSize: number): void;\n public abstract override setScientificType(scientificType: ScientificType): void;\n public abstract override setSpacer(spacer: string): void;\n public abstract override setIncludeZero(includeZero: boolean): void;\n public abstract override setFormatTraits(formatTraits: FormatTraits): void;\n public abstract override setUnits(units: Array<[Unit | InvertedUnit, string | undefined]>): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
1
+ {"version":3,"file":"MutableFormat.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableFormat.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAA0C,MAAM,0BAA0B,CAAC;AAG1F;;;GAGG;AACH,MAAM,OAAgB,aAAc,SAAQ,MAAM;CAkBjD","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Format, LazyLoadedInvertedUnit, LazyLoadedUnit } from \"@itwin/ecschema-metadata\";\nimport { FormatTraits, FormatType, ScientificType, ShowSignOption } from \"@itwin/core-quantity\";\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableFormat extends Format {\n public abstract override addUnit(unit: LazyLoadedUnit | LazyLoadedInvertedUnit, label?: string): void;\n public abstract override setPrecision(precision: number): void;\n public abstract override setFormatType(formatType: FormatType): void;\n public abstract override setRoundFactor(roundFactor: number): void;\n public abstract override setShowSignOption(signOption: ShowSignOption): void;\n public abstract override setDecimalSeparator(separator: string): void;\n public abstract override setThousandSeparator(separator: string): void;\n public abstract override setUomSeparator(separator: string): void;\n public abstract override setStationSeparator(separator: string): void;\n public abstract override setMinWidth(minWidth: number): void;\n public abstract override setStationOffsetSize(stationOffsetSize: number): void;\n public abstract override setScientificType(scientificType: ScientificType): void;\n public abstract override setSpacer(spacer: string): void;\n public abstract override setIncludeZero(includeZero: boolean): void;\n public abstract override setFormatTraits(formatTraits: FormatTraits): void;\n public abstract override setUnits(units: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
@@ -1,14 +1,14 @@
1
- import { Format, InvertedUnit, KindOfQuantity, LazyLoadedInvertedUnit, LazyLoadedUnit, OverrideFormat, Unit } from "@itwin/ecschema-metadata";
1
+ import { Format, KindOfQuantity, LazyLoadedFormat, LazyLoadedInvertedUnit, LazyLoadedUnit, OverrideFormat } from "@itwin/ecschema-metadata";
2
2
  /**
3
3
  * @internal
4
4
  * An abstract class used for schema editing.
5
5
  */
6
6
  export declare abstract class MutableKindOfQuantity extends KindOfQuantity {
7
- abstract addPresentationFormat(format: Format | OverrideFormat, isDefault: boolean): void;
8
- abstract createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): OverrideFormat;
7
+ abstract addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean): void;
8
+ abstract createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat;
9
9
  abstract setDisplayLabel(displayLabel: string): void;
10
10
  abstract setDescription(description: string): void;
11
+ abstract setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void;
11
12
  abstract setRelativeError(relativeError: number): void;
12
- abstract set persistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined);
13
13
  }
14
14
  //# sourceMappingURL=MutableKindOfQuantity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MutableKindOfQuantity.d.ts","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableKindOfQuantity.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,E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,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,sBAAsB,GAAG,SAAS,GAAG,IAAI;aACpF,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;CACvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"MutableKindOfQuantity.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableKindOfQuantity.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAwB,cAAc,EAAgE,MAAM,0BAA0B,CAAC;AAE9I;;;GAGG;AACH,MAAM,OAAgB,qBAAsB,SAAQ,cAAc;CAOjE","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Format, InvertedUnit, KindOfQuantity, LazyLoadedInvertedUnit, LazyLoadedUnit, OverrideFormat, Unit } from \"@itwin/ecschema-metadata\";\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableKindOfQuantity extends KindOfQuantity {\n public abstract override addPresentationFormat(format: Format | OverrideFormat, isDefault: boolean): void;\n public abstract override createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): OverrideFormat;\n public abstract override setDisplayLabel(displayLabel: string): void;\n public abstract override setDescription(description: string): void;\n public abstract override setRelativeError(relativeError: number): void;\n public abstract override set persistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined);\n}\n"]}
1
+ {"version":3,"file":"MutableKindOfQuantity.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableKindOfQuantity.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAU,cAAc,EAA4E,MAAM,0BAA0B,CAAC;AAE5I;;;GAGG;AACH,MAAM,OAAgB,qBAAsB,SAAQ,cAAc;CAOjE","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Format, KindOfQuantity, LazyLoadedFormat, LazyLoadedInvertedUnit, LazyLoadedUnit, OverrideFormat } from \"@itwin/ecschema-metadata\";\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableKindOfQuantity extends KindOfQuantity {\n public abstract override addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean): void;\n public abstract override createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat;\n public abstract override setDisplayLabel(displayLabel: string): void;\n public abstract override setDescription(description: string): void;\n public abstract override setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void;\n public abstract override setRelativeError(relativeError: number): void;\n}\n"]}
@@ -1,16 +1,16 @@
1
- import { CustomAttribute, EntityClass, LazyLoadedRelationshipConstraintClass, Mixin, NavigationProperty, RelationshipClass, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, StrengthDirection, StrengthType } from "@itwin/ecschema-metadata";
1
+ import { CustomAttribute, LazyLoadedRelationshipConstraintClass, NavigationProperty, RelationshipClass, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, StrengthDirection, StrengthType } from "@itwin/ecschema-metadata";
2
2
  /**
3
3
  * Hackish approach that works like a "friend class" so we can access protected members without making them public.
4
4
  * @internal
5
5
  */
6
6
  export declare abstract class MutableRelationshipConstraint extends RelationshipConstraint {
7
7
  abstract addCustomAttribute(customAttribute: CustomAttribute): void;
8
- abstract set multiplicity(multiplicity: RelationshipMultiplicity);
9
- abstract set polymorphic(polymorphic: boolean);
10
- abstract set roleLabel(roleLabel: string | undefined);
11
- abstract set relationshipEnd(relationshipEnd: RelationshipEnd);
12
- abstract set abstractConstraint(abstractConstraint: LazyLoadedRelationshipConstraintClass | undefined);
13
- abstract removeClass(constraint: EntityClass | Mixin | RelationshipClass): void;
8
+ abstract removeClass(constraint: LazyLoadedRelationshipConstraintClass): void;
9
+ abstract setRoleLabel(roleLabel: string | undefined): void;
10
+ abstract setRelationshipEnd(relationshipEnd: RelationshipEnd): void;
11
+ abstract setPolymorphic(polymorphic: boolean): void;
12
+ abstract setMultiplicity(multiplicity: RelationshipMultiplicity): void;
13
+ abstract setAbstractConstraint(abstractConstraint: LazyLoadedRelationshipConstraintClass | undefined): void;
14
14
  }
15
15
  /**
16
16
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"MutableRelationshipClass.d.ts","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableRelationshipClass.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,qCAAqC,EAAE,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,eAAe,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEjQ;;;GAGG;AACH,8BAAsB,6BAA8B,SAAQ,sBAAsB;aACvD,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;IACnF,aAA6B,YAAY,CAAC,YAAY,EAAE,wBAAwB,EAAE;IAClF,aAA6B,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE;IAC/D,aAA6B,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE;IACtE,aAA6B,eAAe,CAAC,eAAe,EAAE,eAAe,EAAG;IAChF,aAA6B,kBAAkB,CAAC,kBAAkB,EAAE,qCAAqC,GAAG,SAAS,EAAE;aAC9F,WAAW,CAAC,UAAU,EAAE,WAAW,GAAG,KAAK,GAAG,iBAAiB,GAAG,IAAI;CAChG;AAED;;;GAGG;AACH,8BAAsB,wBAAyB,SAAQ,iBAAiB;IACtE,IAAoB,MAAM,IAA4B,6BAA6B,CAAG;IACtF,IAAoB,MAAM,IAA4B,6BAA6B,CAAG;aAC7D,WAAW,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AC5H;AAED;;;GAGG;AACH,8BAAsB,wBAAyB,SAAQ,iBAAiB;IACtE,IAAoB,MAAM,IAA4B,6BAA6B,CAAG;IACtF,IAAoB,MAAM,IAA4B,6BAA6B,CAAG;aAC7D,WAAW,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;aACzC,oBAAoB,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI;aACxD,mBAAmB,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;aACzD,mBAAmB,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;aACzD,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;aACpJ,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,kBAAkB;aAC/I,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"MutableRelationshipClass.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableRelationshipClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAkG,iBAAiB,EAAE,sBAAsB,EAA8E,MAAM,0BAA0B,CAAC;AAEjQ;;;GAGG;AACH,MAAM,OAAgB,6BAA8B,SAAQ,sBAAsB;CAQjF;AAED;;;GAGG;AACH,MAAM,OAAgB,wBAAyB,SAAQ,iBAAiB;IACtE,IAAoB,MAAM,KAAK,OAAO,IAAI,CAAC,OAAwC,CAAC,CAAC,CAAC;IACtF,IAAoB,MAAM,KAAK,OAAO,IAAI,CAAC,OAAwC,CAAC,CAAC,CAAC;CAQvF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { CustomAttribute, EntityClass, LazyLoadedRelationshipConstraintClass, Mixin, NavigationProperty, RelationshipClass, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, StrengthDirection, StrengthType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableRelationshipConstraint extends RelationshipConstraint {\n public abstract override addCustomAttribute(customAttribute: CustomAttribute): void;\n public abstract override set multiplicity(multiplicity: RelationshipMultiplicity);\n public abstract override set polymorphic(polymorphic: boolean);\n public abstract override set roleLabel(roleLabel: string | undefined);\n public abstract override set relationshipEnd(relationshipEnd: RelationshipEnd) ;\n public abstract override set abstractConstraint(abstractConstraint: LazyLoadedRelationshipConstraintClass | undefined);\n public abstract override removeClass(constraint: EntityClass | Mixin | RelationshipClass): void;\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableRelationshipClass extends RelationshipClass {\n public override get source() { return this._source as MutableRelationshipConstraint; }\n public override get target() { return this._target as MutableRelationshipConstraint; }\n public abstract override setStrength(strength: StrengthType): void;\n public abstract override setStrengthDirection(direction: StrengthDirection): void;\n public abstract override setSourceConstraint(source: RelationshipConstraint): void;\n public abstract override setTargetConstraint(target: RelationshipConstraint): void;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
1
+ {"version":3,"file":"MutableRelationshipClass.js","sourceRoot":"","sources":["../../../../src/Editing/Mutable/MutableRelationshipClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAA8E,iBAAiB,EAAE,sBAAsB,EAA8E,MAAM,0BAA0B,CAAC;AAE7O;;;GAGG;AACH,MAAM,OAAgB,6BAA8B,SAAQ,sBAAsB;CAQjF;AAED;;;GAGG;AACH,MAAM,OAAgB,wBAAyB,SAAQ,iBAAiB;IACtE,IAAoB,MAAM,KAAK,OAAO,IAAI,CAAC,OAAwC,CAAC,CAAC,CAAC;IACtF,IAAoB,MAAM,KAAK,OAAO,IAAI,CAAC,OAAwC,CAAC,CAAC,CAAC;CAQvF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { CustomAttribute, LazyLoadedRelationshipConstraintClass, NavigationProperty, RelationshipClass, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, StrengthDirection, StrengthType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableRelationshipConstraint extends RelationshipConstraint {\n public abstract override addCustomAttribute(customAttribute: CustomAttribute): void;\n public abstract override removeClass(constraint: LazyLoadedRelationshipConstraintClass): void;\n public abstract override setRoleLabel(roleLabel: string | undefined): void;\n public abstract override setRelationshipEnd(relationshipEnd: RelationshipEnd): void;\n public abstract override setPolymorphic(polymorphic: boolean): void;\n public abstract override setMultiplicity(multiplicity: RelationshipMultiplicity): void;\n public abstract override setAbstractConstraint(abstractConstraint: LazyLoadedRelationshipConstraintClass | undefined): void;\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableRelationshipClass extends RelationshipClass {\n public override get source() { return this._source as MutableRelationshipConstraint; }\n public override get target() { return this._target as MutableRelationshipConstraint; }\n public abstract override setStrength(strength: StrengthType): void;\n public abstract override setStrengthDirection(direction: StrengthDirection): void;\n public abstract override setSourceConstraint(source: RelationshipConstraint): void;\n public abstract override setTargetConstraint(target: RelationshipConstraint): void;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
@@ -25,18 +25,18 @@ export class Properties {
25
25
  .catch((e) => {
26
26
  throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName), e);
27
27
  });
28
- const baseProperty = await existingProperty.class.getProperty(newPropertyName, true);
29
- if (baseProperty) {
30
- throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName), new SchemaEditingError(ECEditingStatus.PropertyAlreadyExists, new PropertyId(this.ecClassType, baseProperty.class.key, newPropertyName)));
28
+ const existingNewProperty = await existingProperty.class.getProperty(newPropertyName);
29
+ if (existingNewProperty) {
30
+ throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName), new SchemaEditingError(ECEditingStatus.PropertyAlreadyExists, new PropertyId(this.ecClassType, existingNewProperty.class.key, newPropertyName)));
31
31
  }
32
32
  // Handle derived classes
33
33
  const derivedProperties = [];
34
34
  const derivedClasses = await this.findDerivedClasses(existingProperty.class);
35
35
  for (const derivedClass of derivedClasses) {
36
- if (await derivedClass.getProperty(newPropertyName)) {
36
+ if (await derivedClass.getProperty(newPropertyName, true)) {
37
37
  throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName), new SchemaEditingError(ECEditingStatus.PropertyAlreadyExists, new PropertyId(this.ecClassType, derivedClass.key, newPropertyName)));
38
38
  }
39
- const propertyOverride = await derivedClass.getProperty(propertyName);
39
+ const propertyOverride = await derivedClass.getProperty(propertyName, true);
40
40
  // If found the property is overridden in the derived class.
41
41
  if (propertyOverride)
42
42
  derivedProperties.push(propertyOverride);
@@ -176,7 +176,7 @@ export class Properties {
176
176
  */
177
177
  async getProperty(classKey, propertyName) {
178
178
  const mutableClass = await this.getClass(classKey);
179
- const property = await mutableClass.getProperty(propertyName);
179
+ const property = await mutableClass.getProperty(propertyName, true);
180
180
  if (property === undefined) {
181
181
  throw new SchemaEditingError(ECEditingStatus.PropertyNotFound, new PropertyId(mutableClass.schemaItemType, classKey, propertyName));
182
182
  }