@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.
Files changed (104) hide show
  1. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  2. package/lib/cjs/Differencing/SchemaDifference.js +2 -2
  3. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  4. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
  5. package/lib/cjs/Differencing/SchemaDifferenceValidator.js +5 -5
  6. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  7. package/lib/cjs/Editing/Constants.d.ts +2 -1
  8. package/lib/cjs/Editing/Constants.d.ts.map +1 -1
  9. package/lib/cjs/Editing/Constants.js +4 -1
  10. package/lib/cjs/Editing/Constants.js.map +1 -1
  11. package/lib/cjs/Editing/CustomAttributes.d.ts +2 -1
  12. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  13. package/lib/cjs/Editing/CustomAttributes.js +3 -0
  14. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  15. package/lib/cjs/Editing/ECClasses.d.ts +6 -0
  16. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  17. package/lib/cjs/Editing/ECClasses.js +23 -16
  18. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  19. package/lib/cjs/Editing/Editor.d.ts +2 -2
  20. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  21. package/lib/cjs/Editing/Editor.js +13 -3
  22. package/lib/cjs/Editing/Editor.js.map +1 -1
  23. package/lib/cjs/Editing/Entities.d.ts +2 -1
  24. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  25. package/lib/cjs/Editing/Entities.js +14 -10
  26. package/lib/cjs/Editing/Entities.js.map +1 -1
  27. package/lib/cjs/Editing/Enumerations.d.ts +2 -1
  28. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  29. package/lib/cjs/Editing/Enumerations.js +6 -3
  30. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  31. package/lib/cjs/Editing/Formats.d.ts +2 -1
  32. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  33. package/lib/cjs/Editing/Formats.js +5 -1
  34. package/lib/cjs/Editing/Formats.js.map +1 -1
  35. package/lib/cjs/Editing/InvertedUnits.d.ts +2 -1
  36. package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
  37. package/lib/cjs/Editing/InvertedUnits.js +10 -6
  38. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  39. package/lib/cjs/Editing/KindOfQuantities.d.ts +2 -1
  40. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  41. package/lib/cjs/Editing/KindOfQuantities.js +11 -7
  42. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  43. package/lib/cjs/Editing/Mixins.d.ts +2 -1
  44. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  45. package/lib/cjs/Editing/Mixins.js +9 -5
  46. package/lib/cjs/Editing/Mixins.js.map +1 -1
  47. package/lib/cjs/Editing/Phenomena.d.ts +2 -1
  48. package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
  49. package/lib/cjs/Editing/Phenomena.js +3 -0
  50. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  51. package/lib/cjs/Editing/Properties.d.ts.map +1 -1
  52. package/lib/cjs/Editing/Properties.js +2 -2
  53. package/lib/cjs/Editing/Properties.js.map +1 -1
  54. package/lib/cjs/Editing/PropertyCategories.d.ts +2 -1
  55. package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
  56. package/lib/cjs/Editing/PropertyCategories.js +5 -1
  57. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  58. package/lib/cjs/Editing/RelationshipClasses.d.ts +1 -0
  59. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  60. package/lib/cjs/Editing/RelationshipClasses.js +9 -5
  61. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  62. package/lib/cjs/Editing/SchemaItems.d.ts +2 -2
  63. package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
  64. package/lib/cjs/Editing/SchemaItems.js +6 -11
  65. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  66. package/lib/cjs/Editing/Structs.d.ts +2 -1
  67. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  68. package/lib/cjs/Editing/Structs.js +3 -0
  69. package/lib/cjs/Editing/Structs.js.map +1 -1
  70. package/lib/cjs/Editing/UnitSystems.d.ts +2 -1
  71. package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
  72. package/lib/cjs/Editing/UnitSystems.js +3 -0
  73. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  74. package/lib/cjs/Editing/Units.d.ts +2 -1
  75. package/lib/cjs/Editing/Units.d.ts.map +1 -1
  76. package/lib/cjs/Editing/Units.js +5 -2
  77. package/lib/cjs/Editing/Units.js.map +1 -1
  78. package/lib/cjs/Merging/ConstantMerger.js +1 -1
  79. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  80. package/lib/cjs/Merging/CustomAttributeMerger.js +7 -2
  81. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  82. package/lib/cjs/Merging/FormatMerger.js +6 -1
  83. package/lib/cjs/Merging/FormatMerger.js.map +1 -1
  84. package/lib/cjs/Merging/PropertyMerger.js +3 -3
  85. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  86. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
  87. package/lib/cjs/Merging/RelationshipClassMerger.js +4 -4
  88. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  89. package/lib/cjs/Merging/SchemaMerger.js +4 -2
  90. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  91. package/lib/cjs/Merging/Utils.js +1 -1
  92. package/lib/cjs/Merging/Utils.js.map +1 -1
  93. package/lib/cjs/Validation/ECRules.js +1 -1
  94. package/lib/cjs/Validation/ECRules.js.map +1 -1
  95. package/lib/cjs/Validation/SchemaCompareVisitor.js +19 -19
  96. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  97. package/lib/cjs/Validation/SchemaComparer.d.ts +2 -2
  98. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  99. package/lib/cjs/Validation/SchemaComparer.js +2 -2
  100. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  101. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  102. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  103. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  104. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItems.d.ts","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAmC,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAClJ,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,MAAM,EAAE,aAAa,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAC7H,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAErH;;;GAGG;AACH,8BAAsB,WAAW;IAC/B,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IACzC,SAAS,CAAC,YAAY,EAAE,mBAAmB,CAAC;gBAEzB,cAAc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EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;cAczJ,yBAAyB,CAAC,CAAC,SAAS,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC;CAS7K"}
@@ -30,10 +30,10 @@ class SchemaItems {
30
30
  async setName(itemKey, name) {
31
31
  try {
32
32
  const schema = await this.getSchema(itemKey.schemaKey);
33
- const ecClass = await schema.getItem(name);
33
+ const ecClass = await schema.getItem(name, this.itemTypeClass);
34
34
  if (ecClass !== undefined)
35
35
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNameAlreadyExists, new Exception_1.SchemaItemId(this.schemaItemType, name, schema.schemaKey));
36
- const mutableItem = await this.getSchemaItem(itemKey);
36
+ const mutableItem = await this.getSchemaItem(itemKey, this.itemTypeClass);
37
37
  const existingName = itemKey.name;
38
38
  mutableItem.setName(name);
39
39
  // Must reset in schema item map
@@ -54,7 +54,7 @@ class SchemaItems {
54
54
  * @param description The new description to set.
55
55
  */
56
56
  async setDescription(schemaItemKey, description) {
57
- const item = await this.getSchemaItem(schemaItemKey)
57
+ const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)
58
58
  .catch((e) => {
59
59
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetDescription, new Exception_1.SchemaItemId(this.schemaItemType, schemaItemKey), e);
60
60
  });
@@ -66,7 +66,7 @@ class SchemaItems {
66
66
  * @param label The new label to set.
67
67
  */
68
68
  async setDisplayLabel(schemaItemKey, label) {
69
- const item = await this.getSchemaItem(schemaItemKey)
69
+ const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)
70
70
  .catch((e) => {
71
71
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetLabel, new Exception_1.SchemaItemId(this.schemaItemType, schemaItemKey), e);
72
72
  });
@@ -78,13 +78,8 @@ class SchemaItems {
78
78
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaNotFound, new Exception_1.SchemaId(schemaKey));
79
79
  return schema;
80
80
  }
81
- async getSchemaItem(schemaItemKey, schemaItemType) {
82
- schemaItemType = schemaItemType ?? this.schemaItemType;
83
- return this.schemaEditor.getSchemaItem(schemaItemKey, schemaItemType);
84
- }
85
- async lookupSchemaItem(schemaOrKey, schemaItemKey, schemaItemType) {
86
- schemaItemType = schemaItemType ?? this.schemaItemType;
87
- return this.schemaEditor.lookupSchemaItem(schemaOrKey, schemaItemKey, schemaItemType);
81
+ async getSchemaItem(schemaItemKey, itemConstructor) {
82
+ return this.schemaEditor.getSchemaItem(schemaItemKey, itemConstructor);
88
83
  }
89
84
  async createSchemaItem(schemaKey, type, create, name, ...args) {
90
85
  const schema = await this.getSchema(schemaKey);
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAkJ;AAElJ,2CAA0F;AAO1F;;;GAGG;AACH,MAAsB,WAAW;IACrB,cAAc,CAAiB;IAC/B,YAAY,CAAsB;IAE5C,YAAmB,cAA8B,EAAE,YAAiC;QAClF,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,OAAO,CAAC,OAAsB,EAAE,IAAY;QACvD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACvD,MAAM,OAAO,GAAG,MA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C,IAAI,CAAC,CAAC;QACpF,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE9B,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA5GD,kCA4GC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { ECObjectsError, ECObjectsStatus, SchemaItem, SchemaItemKey, SchemaItemProps, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\nimport { MutableSchemaItem } from \"./Mutable/MutableSchemaItem\";\n\nexport type CreateSchemaItem<T extends SchemaItem> = (schema: MutableSchema) => (name: string, ...args: any[]) => Promise<T>;\nexport type CreateSchemaItemFromProps<T extends SchemaItem> = (props: SchemaItemProps, ...args: any[]) => Promise<T>;\n\n/**\n * @internal\n * A class allowing you to edit the schema item base class.\n */\nexport abstract class SchemaItems {\n protected schemaItemType: SchemaItemType;\n protected schemaEditor: SchemaContextEditor;\n\n public constructor(schemaItemType: SchemaItemType, schemaEditor: SchemaContextEditor) {\n this.schemaItemType = schemaItemType;\n this.schemaEditor = schemaEditor;\n }\n\n /**\n * Sets the name of the SchemaItem.\n * @param itemKey The SchemaItemKey of the SchemaItem.\n * @param name The new name of the SchemaItem.\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\n */\n public async setName(itemKey: SchemaItemKey, name: string): Promise<SchemaItemKey> {\n try {\n const schema = await this.getSchema(itemKey.schemaKey);\n const ecClass = await schema.getItem<MutableSchemaItem>(name);\n if (ecClass !== undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(this.schemaItemType, name, schema.schemaKey));\n\n const mutableItem = await this.getSchemaItem<MutableSchemaItem>(itemKey);\n\n const existingName = itemKey.name;\n mutableItem.setName(name);\n\n // Must reset in schema item map\n await schema.deleteSchemaItem(existingName);\n schema.addItem(mutableItem);\n return mutableItem.key;\n } catch(e: any) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.InvalidECName) {\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey),\n new SchemaEditingError(ECEditingStatus.InvalidECName, new SchemaItemId(this.schemaItemType, itemKey)));\n }\n\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey), e);\n }\n }\n\n /**\n * Sets the SchemaItem description.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param description The new description to set.\n */\n public async setDescription(schemaItemKey: SchemaItemKey, description: string) {\n const item = await this.getSchemaItem<MutableSchemaItem>(schemaItemKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n item.setDescription(description);\n }\n\n /**\n * Sets the SchemaItem display label.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param label The new label to set.\n */\n public async setDisplayLabel(schemaItemKey: SchemaItemKey, label: string) {\n const item = await this.getSchemaItem<MutableSchemaItem>(schemaItemKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n item.setDisplayLabel(label);\n }\n\n protected async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\n const schema = await this.schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema;\n }\n\n protected async getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey, schemaItemType?: SchemaItemType): Promise<T>{\n schemaItemType = schemaItemType ?? this.schemaItemType;\n return this.schemaEditor.getSchemaItem<T>(schemaItemKey, schemaItemType);\n }\n\n protected async lookupSchemaItem<T extends SchemaItem>(schemaOrKey: MutableSchema | SchemaKey, schemaItemKey: SchemaItemKey, schemaItemType?: SchemaItemType): Promise<T>{\n schemaItemType = schemaItemType ?? this.schemaItemType;\n return this.schemaEditor.lookupSchemaItem(schemaOrKey, schemaItemKey, schemaItemType);\n }\n\n protected async createSchemaItem<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, ...args: any[]): Promise<T> {\n const schema = await this.getSchema(schemaKey);\n try {\n const boundCreate = create(schema);\n return await boundCreate(name, ...args);\n } catch (e) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.DuplicateItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(type, name, schema.schemaKey));\n } else {\n throw new Error(`Failed to create class ${name} in schema ${schema.fullName}.`);\n }\n }\n }\n\n protected async createSchemaItemFromProps<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, props: SchemaItemProps): Promise<T> {\n if (props.name === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameNotSpecified, new SchemaItemId(type, \"\", schemaKey));\n\n const newItem = await this.createSchemaItem<T>(schemaKey, type, create, props.name);\n await newItem.fromJSON(props);\n\n return newItem;\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAkJ;AAElJ,2CAA0F;AAO1F;;;GAGG;AACH,MAAsB,WAAW;IACrB,cAAc,CAAiB;IAC/B,YAAY,CAAsB;IAI5C,YAAmB,cAA8B,EAAE,YAAiC;QAClF,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IA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CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE9B,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAxGD,kCAwGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { ECObjectsError, ECObjectsStatus, SchemaItem, SchemaItemKey, SchemaItemProps, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\nimport { MutableSchemaItem } from \"./Mutable/MutableSchemaItem\";\n\nexport type CreateSchemaItem<T extends SchemaItem> = (schema: MutableSchema) => (name: string, ...args: any[]) => Promise<T>;\nexport type CreateSchemaItemFromProps<T extends SchemaItem> = (props: SchemaItemProps, ...args: any[]) => Promise<T>;\n\n/**\n * @internal\n * A class allowing you to edit the schema item base class.\n */\nexport abstract class SchemaItems {\n protected schemaItemType: SchemaItemType;\n protected schemaEditor: SchemaContextEditor;\n\n protected abstract get itemTypeClass(): typeof SchemaItem;\n\n public constructor(schemaItemType: SchemaItemType, schemaEditor: SchemaContextEditor) {\n this.schemaItemType = schemaItemType;\n this.schemaEditor = schemaEditor;\n }\n\n /**\n * Sets the name of the SchemaItem.\n * @param itemKey The SchemaItemKey of the SchemaItem.\n * @param name The new name of the SchemaItem.\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\n */\n public async setName(itemKey: SchemaItemKey, name: string): Promise<SchemaItemKey> {\n try {\n const schema = await this.getSchema(itemKey.schemaKey);\n const ecClass = await schema.getItem(name, this.itemTypeClass);\n if (ecClass !== undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(this.schemaItemType, name, schema.schemaKey));\n\n const mutableItem = await this.getSchemaItem(itemKey, this.itemTypeClass) as MutableSchemaItem;\n\n const existingName = itemKey.name;\n mutableItem.setName(name);\n\n // Must reset in schema item map\n await schema.deleteSchemaItem(existingName);\n schema.addItem(mutableItem);\n return mutableItem.key;\n } catch(e: any) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.InvalidECName) {\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey),\n new SchemaEditingError(ECEditingStatus.InvalidECName, new SchemaItemId(this.schemaItemType, itemKey)));\n }\n\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey), e);\n }\n }\n\n /**\n * Sets the SchemaItem description.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param description The new description to set.\n */\n public async setDescription(schemaItemKey: SchemaItemKey, description: string) {\n const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n (item as MutableSchemaItem).setDescription(description);\n }\n\n /**\n * Sets the SchemaItem display label.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param label The new label to set.\n */\n public async setDisplayLabel(schemaItemKey: SchemaItemKey, label: string) {\n const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n (item as MutableSchemaItem).setDisplayLabel(label);\n }\n\n protected async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\n const schema = await this.schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema;\n }\n\n protected async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T>> {\n return this.schemaEditor.getSchemaItem(schemaItemKey, itemConstructor);\n }\n\n protected async createSchemaItem<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, ...args: any[]): Promise<T> {\n const schema = await this.getSchema(schemaKey);\n try {\n const boundCreate = create(schema);\n return await boundCreate(name, ...args);\n } catch (e) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.DuplicateItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(type, name, schema.schemaKey));\n } else {\n throw new Error(`Failed to create class ${name} in schema ${schema.fullName}.`);\n }\n }\n }\n\n protected async createSchemaItemFromProps<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, props: SchemaItemProps): Promise<T> {\n if (props.name === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameNotSpecified, new SchemaItemId(type, \"\", schemaKey));\n\n const newItem = await this.createSchemaItem<T>(schemaKey, type, create, props.name);\n await newItem.fromJSON(props);\n\n return newItem;\n }\n}\n"]}
@@ -1,13 +1,14 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { SchemaItemKey, SchemaKey, StructClassProps } from "@itwin/ecschema-metadata";
4
+ import { SchemaItemKey, SchemaKey, StructClass, StructClassProps } from "@itwin/ecschema-metadata";
5
5
  import { SchemaContextEditor } from "./Editor";
6
6
  import { ECClasses } from "./ECClasses";
7
7
  /**
8
8
  * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.
9
9
  */
10
10
  export declare class Structs extends ECClasses {
11
+ protected get itemTypeClass(): typeof StructClass;
11
12
  constructor(schemaEditor: SchemaContextEditor);
12
13
  create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey>;
13
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Structs.d.ts","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAe,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC;;GAEG;AACH,qBAAa,OAAQ,SAAQ,SAAS;gBACjB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAapI;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ1G"}
1
+ {"version":3,"file":"Structs.d.ts","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC;;GAEG;AACH,qBAAa,OAAQ,SAAQ,SAAS;IACpC,cAAuB,aAAa,IAAI,OAAO,WAAW,CAEzD;gBAEkB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAapI;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ1G"}
@@ -15,6 +15,9 @@ const Exception_1 = require("./Exception");
15
15
  * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.
16
16
  */
17
17
  class Structs extends ECClasses_1.ECClasses {
18
+ get itemTypeClass() {
19
+ return ecschema_metadata_1.StructClass;
20
+ }
18
21
  constructor(schemaEditor) {
19
22
  super(ecschema_metadata_1.SchemaItemType.StructClass, schemaEditor);
20
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAmH;AAEnH,2CAAwC;AAExC,2CAA2E;AAE3E;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,YAA4B;QACzG,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAc,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,CAAuB,CAAC;YAElL,IAAI,YAAY;gBACd,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEzC,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAA6B;QAC9E,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;YACtJ,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC;CACF;AA/BD,0BA+BC","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 { SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableStructClass } from \"./Mutable/MutableClass\";\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\n\n/**\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\n */\nexport class Structs extends ECClasses {\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.StructClass, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<StructClass>(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), name, baseClassKey) as MutableStructClass;\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 a StructClass through a StructClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), structProps);\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, structProps.name!, schemaKey), e);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAmH;AAEnH,2CAAwC;AAExC,2CAA2E;AAE3E;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,IAAuB,aAAa;QAClC,OAAO,+BAAW,CAAC;IACrB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,YAA4B;QACzG,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAc,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,CAAuB,CAAC;YAElL,IAAI,YAAY;gBACd,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEzC,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAA6B;QAC9E,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;YACtJ,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC;CACF;AAnCD,0BAmCC","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 { SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableStructClass } from \"./Mutable/MutableClass\";\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\n\n/**\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\n */\nexport class Structs extends ECClasses {\n protected override get itemTypeClass(): typeof StructClass {\n return StructClass;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.StructClass, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<StructClass>(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), name, baseClassKey) as MutableStructClass;\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 a StructClass through a StructClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), structProps);\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, structProps.name!, schemaKey), e);\n }\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { SchemaItemKey, SchemaKey, UnitSystemProps } from "@itwin/ecschema-metadata";
4
+ import { SchemaItemKey, SchemaKey, UnitSystem, UnitSystemProps } 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 UnitSystems.
10
10
  */
11
11
  export declare class UnitSystems extends SchemaItems {
12
+ protected get itemTypeClass(): typeof UnitSystem;
12
13
  constructor(schemaEditor: SchemaContextEditor);
13
14
  create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey>;
14
15
  createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey>;
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSystems.d.ts","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAc,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAY,SAAQ,WAAW;gBACvB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAczF,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ7G"}
1
+ {"version":3,"file":"UnitSystems.d.ts","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAY,SAAQ,WAAW;IAC1C,cAAuB,aAAa,IAAI,OAAO,UAAU,CAExD;gBAEkB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAczF,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ7G"}
@@ -16,6 +16,9 @@ const SchemaItems_1 = require("./SchemaItems");
16
16
  * A class allowing you to create schema items of type UnitSystems.
17
17
  */
18
18
  class UnitSystems extends SchemaItems_1.SchemaItems {
19
+ get itemTypeClass() {
20
+ return ecschema_metadata_1.UnitSystem;
21
+ }
19
22
  constructor(schemaEditor) {
20
23
  super(ecschema_metadata_1.SchemaItemType.UnitSystem, schemaEditor);
21
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiH;AAGjH,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,WAAY,SAAQ,yBAAW;IAC1C,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAE3E,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAsB,CAAC;YAE3K,IAAI,YAAY;gBACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAE9C,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,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;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC;YAC9J,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;CACF;AA3BD,kCA2BC","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 { SchemaItemKey, SchemaItemType, SchemaKey, UnitSystem, UnitSystemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\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 UnitSystems.\n */\nexport class UnitSystems extends SchemaItems {\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.UnitSystem, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey> {\n\n try {\n const newUnitSystem = await this.createSchemaItem<UnitSystem>(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), name) as MutableUnitSystem;\n\n if (displayLabel)\n newUnitSystem.setDisplayLabel(displayLabel);\n\n return newUnitSystem.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, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey> {\n try {\n const newUnitSystem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), unitSystemProps);\n return newUnitSystem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitSystemProps.name!, schemaKey), e);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiH;AAGjH,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,WAAY,SAAQ,yBAAW;IAC1C,IAAuB,aAAa;QAClC,OAAO,8BAAU,CAAC;IACpB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAE3E,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAsB,CAAC;YAE3K,IAAI,YAAY;gBACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAE9C,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,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;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC;YAC9J,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;CACF;AA/BD,kCA+BC","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 { SchemaItemKey, SchemaItemType, SchemaKey, UnitSystem, UnitSystemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\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 UnitSystems.\n */\nexport class UnitSystems extends SchemaItems {\n protected override get itemTypeClass(): typeof UnitSystem {\n return UnitSystem;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.UnitSystem, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey> {\n\n try {\n const newUnitSystem = await this.createSchemaItem<UnitSystem>(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), name) as MutableUnitSystem;\n\n if (displayLabel)\n newUnitSystem.setDisplayLabel(displayLabel);\n\n return newUnitSystem.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, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey> {\n try {\n const newUnitSystem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), unitSystemProps);\n return newUnitSystem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitSystemProps.name!, schemaKey), e);\n }\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { SchemaItemKey, SchemaItemUnitProps, SchemaKey } from "@itwin/ecschema-metadata";
4
+ import { SchemaItemKey, SchemaItemUnitProps, 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 Unit.
10
10
  */
11
11
  export declare class Units extends SchemaItems {
12
+ protected get itemTypeClass(): typeof Unit;
12
13
  constructor(schemaEditor: SchemaContextEditor);
13
14
  create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey>;
14
15
  createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey>;
@@ -1 +1 @@
1
- {"version":3,"file":"Units.d.ts","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAuC,aAAa,EAAkB,mBAAmB,EAAE,SAAS,EAAoB,MAAM,0BAA0B,CAAC;AAChK,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,KAAM,SAAQ,WAAW;gBAEjB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBnK,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ3G"}
1
+ {"version":3,"file":"Units.d.ts","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAuC,aAAa,EAAkB,mBAAmB,EAAE,SAAS,EAAE,IAAI,EAAc,MAAM,0BAA0B,CAAC;AAChK,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,KAAM,SAAQ,WAAW;IACpC,cAAuB,aAAa,IAAI,OAAO,IAAI,CAElD;gBAGkB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBnK,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ3G"}
@@ -16,6 +16,9 @@ const SchemaItems_1 = require("./SchemaItems");
16
16
  * A class allowing you to create schema items of type Unit.
17
17
  */
18
18
  class Units extends SchemaItems_1.SchemaItems {
19
+ get itemTypeClass() {
20
+ return ecschema_metadata_1.Unit;
21
+ }
19
22
  // TODO: Add more setters for all attributes.
20
23
  constructor(schemaEditor) {
21
24
  super(ecschema_metadata_1.SchemaItemType.Unit, schemaEditor);
@@ -23,9 +26,9 @@ class Units extends SchemaItems_1.SchemaItems {
23
26
  async create(schemaKey, name, definition, phenomenon, unitSystem, displayLabel) {
24
27
  try {
25
28
  const newUnit = await this.createSchemaItem(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name);
26
- const phenomenonItem = await this.lookupSchemaItem(newUnit.schema.schemaKey, phenomenon, ecschema_metadata_1.SchemaItemType.Phenomenon);
29
+ const phenomenonItem = await this.getSchemaItem(phenomenon, ecschema_metadata_1.Phenomenon);
27
30
  await newUnit.setPhenomenon(new ecschema_metadata_1.DelayedPromiseWithProps(phenomenon, async () => phenomenonItem));
28
- const unitSystemItem = await this.lookupSchemaItem(newUnit.schema.schemaKey, unitSystem, ecschema_metadata_1.SchemaItemType.UnitSystem);
31
+ const unitSystemItem = await this.getSchemaItem(unitSystem, ecschema_metadata_1.UnitSystem);
29
32
  await newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystem, async () => unitSystemItem));
30
33
  await newUnit.setDefinition(definition);
31
34
  if (displayLabel)
@@ -1 +1 @@
1
- {"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GA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AC;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;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA8B;QAC/E,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;YAC5I,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAChJ,CAAC;IACH,CAAC;CACF;AAnCD,sBAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, Unit, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\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 Unit.\n */\nexport class Units extends SchemaItems {\n // TODO: Add more setters for all attributes.\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Unit, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItem<Unit>(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name) as MutableUnit;\n\n const phenomenonItem = await this.lookupSchemaItem<Phenomenon>(newUnit.schema.schemaKey, phenomenon, SchemaItemType.Phenomenon);\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\n\n const unitSystemItem = await this.lookupSchemaItem<UnitSystem>(newUnit.schema.schemaKey, unitSystem, SchemaItemType.UnitSystem);\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\n\n await newUnit.setDefinition(definition);\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return 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, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAgK;AAGhK,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,KAAM,SAAQ,yBAAW;IACpC,IAAuB,aAAa;QAClC,OAAO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AC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA8B;QAC/E,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;YAC5I,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAChJ,CAAC;IACH,CAAC;CACF;AAvCD,sBAuCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, Unit, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\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 Unit.\n */\nexport class Units extends SchemaItems {\n protected override get itemTypeClass(): typeof Unit {\n return Unit;\n }\n\n // TODO: Add more setters for all attributes.\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Unit, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItem<Unit>(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name) as MutableUnit;\n\n const phenomenonItem = await this.getSchemaItem(phenomenon, Phenomenon);\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\n\n const unitSystemItem = await this.getSchemaItem(unitSystem, UnitSystem);\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\n\n await newUnit.setDefinition(definition);\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return 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, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);\n }\n }\n}\n"]}
@@ -58,7 +58,7 @@ async function modifyConstant(context, change, itemKey) {
58
58
  }
59
59
  if (change.difference.phenomenon !== undefined) {
60
60
  const lookupKey = await (0, Utils_1.updateSchemaItemKey)(context, change.difference.phenomenon);
61
- const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey);
61
+ const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey, ecschema_metadata_1.Phenomenon);
62
62
  if (phenomenon === undefined) {
63
63
  throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);
64
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAcA,kC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ACnI,CAAC;QACD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAa,SAAS,CAAC,CAAC;QAC3F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAC5F,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,CAAC;AACH,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*--------------------------------------------------------------------------------------------*/\nimport type { ConstantDifference } from \"../Differencing/SchemaDifference\";\nimport type{ MutableConstant } from \"../Editing/Mutable/MutableConstant\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Constant into the target schema.\n * @internal\n */\nexport async function addConstant(context: SchemaMergeContext, change: ConstantDifference) {\n if (change.difference.phenomenon === undefined) {\n throw new Error(\"Constant must define phenomenon\");\n }\n if (change.difference.definition === undefined) {\n throw new Error(\"Constant must define definition\");\n }\n\n // Needs to update the reference from source to target schema.\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\n\n await context.editor.constants.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n phenomenon: change.difference.phenomenon,\n definition: change.difference.definition,\n });\n}\n\n/**\n * Merges differences to an existing Constant in the target schema.\n * @internal\n */\nexport async function modifyConstant(context: SchemaMergeContext, change: ConstantDifference, itemKey: SchemaItemKey) {\n const constant = await context.targetSchema.lookupItem(itemKey) as MutableConstant;\n if (change.difference.label !== undefined) {\n await context.editor.constants.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.constants.setDescription(itemKey, change.difference.description);\n }\n\n // Note: There are no editor methods to modify a constant.\n if (change.difference.definition !== undefined) {\n if (change.difference.definition !== \"\" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'definition' attribute.`);\n }\n constant.setDefinition(change.difference.definition);\n }\n if (change.difference.denominator !== undefined) {\n if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'denominator' attribute.`);\n }\n constant.setDenominator(change.difference.denominator);\n }\n if (change.difference.numerator !== undefined) {\n if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'numerator' attribute.`);\n }\n constant.setNumerator(change.difference.numerator);\n }\n if (change.difference.phenomenon !== undefined) {\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\n const phenomenon = await context.editor.schemaContext.getSchemaItem<Phenomenon>(lookupKey);\n if (phenomenon === undefined) {\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\n }\n\n constant.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\n }\n}\n"]}
1
+ {"version":3,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CAAC,mCAAe,CAAC,aAAa,EAAE,gBAAgB,MAAM,CAAC,QAAQ,wCAAwC,CAAC,CAAC;QACnI,CAAC;QACD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,8BAAU,CAAC,CAAC;QAC3F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAC5F,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,CAAC;AACH,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*--------------------------------------------------------------------------------------------*/\nimport type { ConstantDifference } from \"../Differencing/SchemaDifference\";\nimport type{ MutableConstant } from \"../Editing/Mutable/MutableConstant\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Constant into the target schema.\n * @internal\n */\nexport async function addConstant(context: SchemaMergeContext, change: ConstantDifference) {\n if (change.difference.phenomenon === undefined) {\n throw new Error(\"Constant must define phenomenon\");\n }\n if (change.difference.definition === undefined) {\n throw new Error(\"Constant must define definition\");\n }\n\n // Needs to update the reference from source to target schema.\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\n\n await context.editor.constants.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n phenomenon: change.difference.phenomenon,\n definition: change.difference.definition,\n });\n}\n\n/**\n * Merges differences to an existing Constant in the target schema.\n * @internal\n */\nexport async function modifyConstant(context: SchemaMergeContext, change: ConstantDifference, itemKey: SchemaItemKey) {\n const constant = await context.targetSchema.lookupItem(itemKey) as MutableConstant;\n if (change.difference.label !== undefined) {\n await context.editor.constants.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.constants.setDescription(itemKey, change.difference.description);\n }\n\n // Note: There are no editor methods to modify a constant.\n if (change.difference.definition !== undefined) {\n if (change.difference.definition !== \"\" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'definition' attribute.`);\n }\n constant.setDefinition(change.difference.definition);\n }\n if (change.difference.denominator !== undefined) {\n if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'denominator' attribute.`);\n }\n constant.setDenominator(change.difference.denominator);\n }\n if (change.difference.numerator !== undefined) {\n if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'numerator' attribute.`);\n }\n constant.setNumerator(change.difference.numerator);\n }\n if (change.difference.phenomenon !== undefined) {\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\n const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey, Phenomenon);\n if (phenomenon === undefined) {\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\n }\n\n constant.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\n }\n}\n"]}
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addCustomAttribute = addCustomAttribute;
4
4
  exports.applyCustomAttributes = applyCustomAttributes;
5
5
  exports.applyCustomAttribute = applyCustomAttribute;
6
+ /*---------------------------------------------------------------------------------------------
7
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
8
+ * See LICENSE.md in the project root for license terms and full copyright notice.
9
+ *--------------------------------------------------------------------------------------------*/
10
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
6
11
  const Utils_1 = require("./Utils");
7
12
  /**
8
13
  * Merges a new CustomAttributes from Schema, items or properties into the target schema.
@@ -13,7 +18,7 @@ async function addCustomAttribute(context, change) {
13
18
  throw new Error("CustomAttribute instance must specify className");
14
19
  }
15
20
  const schemaItemKey = await (0, Utils_1.updateSchemaItemKey)(context, change.difference.className);
16
- const targetCustomAttributeClass = await context.targetSchema.lookupItem(schemaItemKey);
21
+ const targetCustomAttributeClass = await context.targetSchema.lookupItem(schemaItemKey, ecschema_metadata_1.CustomAttributeClass);
17
22
  if (targetCustomAttributeClass === undefined) {
18
23
  throw new Error(`Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`);
19
24
  }
@@ -38,7 +43,7 @@ async function addCustomAttribute(context, change) {
38
43
  }
39
44
  if (change.appliedTo === "RelationshipConstraint") {
40
45
  const itemKey = (0, Utils_1.toItemKey)(context, change.itemName);
41
- const relationshipClass = await context.targetSchema.lookupItem(itemKey);
46
+ const relationshipClass = await context.targetSchema.lookupItem(itemKey, ecschema_metadata_1.RelationshipClass);
42
47
  if (relationshipClass === undefined) {
43
48
  throw new Error(`Unable to locate the relationship class ${itemKey.name} in the merged schema.`);
44
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"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AC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,eAAgC,EAAE,OAA8B;IACtI,eAAe,CAAC,SAAS,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC,eAAe,CAAC,CAAC;AAClC,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*--------------------------------------------------------------------------------------------*/\nimport { CustomAttribute, CustomAttributeClass, RelationshipClass } from \"@itwin/ecschema-metadata\";\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\nimport { type CustomAttributeDifference } from \"../Differencing/SchemaDifference\";\nimport { getClassEditor, toItemKey, toPropertyKey, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\ntype CustomAttributeSetter = (customAttribute: CustomAttribute) => Promise<void>;\n\n/**\n * Merges a new CustomAttributes from Schema, items or properties into the target schema.\n * @internal\n */\nexport async function addCustomAttribute(context: SchemaMergeContext, change: CustomAttributeDifference): Promise<void> {\n if (change.difference.className === undefined) {\n throw new Error(\"CustomAttribute instance must specify className\");\n }\n const schemaItemKey = await updateSchemaItemKey(context, change.difference.className);\n\n const targetCustomAttributeClass = await context.targetSchema.lookupItem<CustomAttributeClass>(schemaItemKey);\n if (targetCustomAttributeClass === undefined) {\n throw new Error(`Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`);\n }\n\n const caInstance: CustomAttribute = {\n ...change.difference,\n className: schemaItemKey.fullName,\n };\n\n if (change.appliedTo === \"Schema\") {\n await context.editor.addCustomAttribute(context.targetSchemaKey, caInstance);\n }\n if (change.appliedTo === \"SchemaItem\") {\n const itemKey = toItemKey(context, change.itemName);\n const editor = await getClassEditor(context, itemKey);\n await editor.addCustomAttribute(itemKey, caInstance);\n }\n if (change.appliedTo === \"Property\") {\n const itemKey = toItemKey(context, change.itemName); \n const [propertyName] = change.path.split(\".\");\n const propertyKey = toPropertyKey(context, change.itemName, propertyName);\n const editor = await getClassEditor(context, itemKey);\n await editor.properties.addCustomAttribute(itemKey, propertyKey.propertyName, caInstance);\n }\n if (change.appliedTo === \"RelationshipConstraint\") {\n const itemKey = toItemKey(context, change.itemName);\n const relationshipClass = await context.targetSchema.lookupItem<RelationshipClass>(itemKey);\n if (relationshipClass === undefined) {\n throw new Error(`Unable to locate the relationship class ${itemKey.name} in the merged schema.`);\n }\n const constraint = change.path === \"$source\"\n ? relationshipClass.source\n : relationshipClass.target;\n\n return context.editor.relationships.addCustomAttributeToConstraint(constraint, caInstance);\n }\n}\n\n/**\n * @internal\n */\nexport async function applyCustomAttributes(context: SchemaMergeContext, customAttributes: CustomAttribute[], handler: CustomAttributeSetter): Promise<void> {\n for (const customAttribute of customAttributes) {\n await applyCustomAttribute(context, customAttribute, handler);\n }\n}\n\n/**\n * @internal\n */\nexport async function applyCustomAttribute(context: SchemaMergeContext, customAttribute: CustomAttribute, handler: CustomAttributeSetter): Promise<void> {\n customAttribute.className = await updateSchemaItemFullName(context, customAttribute.className);\n return handler(customAttribute);\n}\n"]}
1
+ {"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";;AAeA,gDA2CC;AAKD,sDAIC;AAKD,oDAGC;AA3ED;;;+FAG+F;AAC/F,gEAAoG;AAGpG,mCAAkH;AAIlH;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CAAC,OAA2B,EAAE,MAAiC;IACrG,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAmB,EAAC,O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C,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*--------------------------------------------------------------------------------------------*/\nimport { CustomAttribute, CustomAttributeClass, RelationshipClass } from \"@itwin/ecschema-metadata\";\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\nimport { type CustomAttributeDifference } from \"../Differencing/SchemaDifference\";\nimport { getClassEditor, toItemKey, toPropertyKey, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\ntype CustomAttributeSetter = (customAttribute: CustomAttribute) => Promise<void>;\n\n/**\n * Merges a new CustomAttributes from Schema, items or properties into the target schema.\n * @internal\n */\nexport async function addCustomAttribute(context: SchemaMergeContext, change: CustomAttributeDifference): Promise<void> {\n if (change.difference.className === undefined) {\n throw new Error(\"CustomAttribute instance must specify className\");\n }\n const schemaItemKey = await updateSchemaItemKey(context, change.difference.className);\n\n const targetCustomAttributeClass = await context.targetSchema.lookupItem(schemaItemKey, CustomAttributeClass);\n if (targetCustomAttributeClass === undefined) {\n throw new Error(`Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`);\n }\n\n const caInstance: CustomAttribute = {\n ...change.difference,\n className: schemaItemKey.fullName,\n };\n\n if (change.appliedTo === \"Schema\") {\n await context.editor.addCustomAttribute(context.targetSchemaKey, caInstance);\n }\n if (change.appliedTo === \"SchemaItem\") {\n const itemKey = toItemKey(context, change.itemName);\n const editor = await getClassEditor(context, itemKey);\n await editor.addCustomAttribute(itemKey, caInstance);\n }\n if (change.appliedTo === \"Property\") {\n const itemKey = toItemKey(context, change.itemName);\n const [propertyName] = change.path.split(\".\");\n const propertyKey = toPropertyKey(context, change.itemName, propertyName);\n const editor = await getClassEditor(context, itemKey);\n await editor.properties.addCustomAttribute(itemKey, propertyKey.propertyName, caInstance);\n }\n if (change.appliedTo === \"RelationshipConstraint\") {\n const itemKey = toItemKey(context, change.itemName);\n const relationshipClass = await context.targetSchema.lookupItem(itemKey, RelationshipClass);\n if (relationshipClass === undefined) {\n throw new Error(`Unable to locate the relationship class ${itemKey.name} in the merged schema.`);\n }\n const constraint = change.path === \"$source\"\n ? relationshipClass.source\n : relationshipClass.target;\n\n return context.editor.relationships.addCustomAttributeToConstraint(constraint, caInstance);\n }\n}\n\n/**\n * @internal\n */\nexport async function applyCustomAttributes(context: SchemaMergeContext, customAttributes: CustomAttribute[], handler: CustomAttributeSetter): Promise<void> {\n for (const customAttribute of customAttributes) {\n await applyCustomAttribute(context, customAttribute, handler);\n }\n}\n\n/**\n * @internal\n */\nexport async function applyCustomAttribute(context: SchemaMergeContext, customAttribute: CustomAttribute, handler: CustomAttributeSetter): Promise<void> {\n customAttribute.className = await updateSchemaItemFullName(context, customAttribute.className);\n return handler(customAttribute);\n}\n"]}
@@ -4,6 +4,11 @@ exports.addFormat = addFormat;
4
4
  exports.modifyFormat = modifyFormat;
5
5
  exports.modifyFormatUnit = modifyFormatUnit;
6
6
  exports.modifyFormatUnitLabel = modifyFormatUnitLabel;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
7
12
  const core_quantity_1 = require("@itwin/core-quantity");
8
13
  const Utils_1 = require("./Utils");
9
14
  /**
@@ -101,7 +106,7 @@ async function modifyFormatUnit(context, change, itemKey) {
101
106
  for (const { name, label } of change.difference) {
102
107
  const lookupKey = await (0, Utils_1.updateSchemaItemKey)(context, name);
103
108
  const formatUnit = await context.editor.schemaContext.getSchemaItem(lookupKey);
104
- if (formatUnit === undefined) {
109
+ if (formatUnit === undefined || (!ecschema_metadata_1.Unit.isUnit(formatUnit) && !ecschema_metadata_1.InvertedUnit.isInvertedUnit(formatUnit))) {
105
110
  throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);
106
111
  }
107
112
  units.push([formatUnit, label]);
@@ -1 +1 @@
1
- {"version":3,"file":"FormatMerger.js","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":";;AAeA,8BAsBC;AAMD,oCAwDC;AAMD,4CAaC;AAMD,sDAYC;AAnID,wDAAgH;AAIhH,mCAAwE;AAExE;;;GAGG;AACI,KAAK,UAAU,SAAS,CAAC,OAA2B,EAAE,MAAwB;IACnF,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACrE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9E,MAAM,iBAAiB,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;YACjH,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG;gBACzC,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK;aACtD,CAAA;QACH,CAAC;IACH,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACpE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,IAAI,EAAE,MAAM,CAAC,U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EAAE,CAAC;QACrD,MAAM,WAAW,GAAG,IAAA,gCAAgB,EAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;QACrE,YAAY,GAAG,YAAY,GAAG,WAAW,CAAC;IAC5C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,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*--------------------------------------------------------------------------------------------*/\nimport { InvertedUnit, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatTraits, parseFormatTrait, parseScientificType, parseShowSignOption } from \"@itwin/core-quantity\";\nimport { FormatDifference, FormatUnitDifference, FormatUnitLabelDifference } from \"../Differencing/SchemaDifference\";\nimport { MutableFormat } from \"../Editing/Mutable/MutableFormat\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Format into the target schema.\n * @internal\n */\nexport async function addFormat(context: SchemaMergeContext, change: FormatDifference) {\n if (change.difference.type === undefined) {\n throw new Error(\"Format must define type\");\n }\n\n if (change.difference.composite && change.difference.composite.units) {\n for (let index = 0; index < change.difference.composite.units.length; index++) {\n const compositeUnitName = await updateSchemaItemFullName(context, change.difference.composite.units[index].name);\n change.difference.composite.units[index] = {\n name: compositeUnitName,\n label: change.difference.composite.units[index].label,\n }\n }\n }\n\n await context.editor.formats.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n type: change.difference.type,\n composite: change.difference.composite,\n });\n}\n\n/**\n * Merges differences to an existing Format in the target schema.\n * @internal\n */\nexport async function modifyFormat(context: SchemaMergeContext, change: FormatDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n if (change.difference.type !== undefined) {\n throw new Error(`Changing the format '${change.itemName}' type is not supported.`);\n }\n\n if (change.difference.label !== undefined) {\n await context.editor.formats.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.formats.setDescription(itemKey, change.difference.description);\n }\n if (change.difference.precision !== undefined) {\n format.setPrecision(change.difference.precision);\n }\n if (change.difference.roundFactor !== undefined) {\n format.setRoundFactor(change.difference.roundFactor);\n }\n if (change.difference.minWidth !== undefined) {\n format.setMinWidth(change.difference.minWidth);\n }\n if (change.difference.showSignOption !== undefined) {\n const showSignOption = parseShowSignOption(change.difference.showSignOption, change.itemName);\n format.setShowSignOption(showSignOption);\n }\n if (change.difference.formatTraits !== undefined) {\n const formatTraits = parseFormatTraits(change.difference.formatTraits, change.itemName);\n format.setFormatTraits(formatTraits);\n }\n if (change.difference.decimalSeparator !== undefined) {\n format.setDecimalSeparator(change.difference.decimalSeparator);\n }\n if (change.difference.thousandSeparator !== undefined) {\n format.setThousandSeparator(change.difference.thousandSeparator);\n }\n if (change.difference.uomSeparator !== undefined) {\n format.setUomSeparator(change.difference.uomSeparator);\n }\n if (change.difference.scientificType !== undefined) {\n const scientificType = parseScientificType(change.difference.scientificType, change.itemName);\n format.setScientificType(scientificType);\n }\n if (change.difference.stationOffsetSize !== undefined) {\n format.setStationOffsetSize(change.difference.stationOffsetSize);\n }\n if (change.difference.stationSeparator !== undefined) {\n format.setStationSeparator(change.difference.stationSeparator);\n }\n if (change.difference.composite !== undefined) {\n if (change.difference.composite.includeZero !== undefined) {\n format.setIncludeZero(change.difference.composite.includeZero);\n }\n if (change.difference.composite.spacer !== undefined) {\n format.setSpacer(change.difference.composite.spacer);\n }\n }\n}\n\n/**\n * Merges source format units into the target format\n * @internal\n*/\nexport async function modifyFormatUnit(context: SchemaMergeContext, change: FormatUnitDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n const units: [Unit | InvertedUnit, string | undefined][] = [];\n for (const { name, label } of change.difference) {\n const lookupKey = await updateSchemaItemKey(context, name);\n const formatUnit = await context.editor.schemaContext.getSchemaItem<Unit | InvertedUnit>(lookupKey);\n if (formatUnit === undefined) {\n throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);\n }\n units.push([formatUnit, label]);\n }\n format.setUnits(units);\n}\n\n/**\n * Overrides format unit label\n * @internal\n*/\nexport async function modifyFormatUnitLabel(context: SchemaMergeContext, change: FormatUnitLabelDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n if (format.units !== undefined) {\n const unitKey = await updateSchemaItemKey(context, change.path);\n /* eslint-disable @typescript-eslint/prefer-for-of */\n for (let index = 0; index < format.units.length; index++) {\n if (format.units[index][0].key.matches(unitKey)) {\n format.units[index][1] = change.difference.label;\n }\n }\n }\n}\n\nfunction parseFormatTraits(formatTraitsFromJson: string | string[], formatName: string): FormatTraits {\n let formatTraits: FormatTraits = FormatTraits.Uninitialized;\n const formatTraitIterable = Array.isArray(formatTraitsFromJson)\n ? formatTraitsFromJson\n : formatTraitsFromJson.split(/,|;|\\|/);\n for (const formatTraitsString of formatTraitIterable) {\n const formatTrait = parseFormatTrait(formatTraitsString, formatName);\n formatTraits = formatTraits | formatTrait;\n }\n return formatTraits;\n}\n"]}
1
+ {"version":3,"file":"FormatMerger.js","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":";;AAeA,8BAsBC;AAMD,oCAwDC;AAMD,4CAaC;AAMD,sDAYC;AAxID;;;+FAG+F;AAC/F,gEAA6E;AAC7E,wDAAgH;AAIhH,mCAAwE;AAExE;;;GAGG;AACI,KAAK,UAAU,SAAS,CAAC,OAA2B,EAAE,MAAwB;IACnF,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,K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O,CAAkB,CAAC;IAE/E,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAChE,qDAAqD;QACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACzD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAChD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,oBAAuC,EAAE,UAAkB;IACpF,IAAI,YAAY,GAAiB,4BAAY,CAAC,aAAa,CAAC;IAC5D,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAC7D,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzC,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACrD,MAAM,WAAW,GAAG,IAAA,gCAAgB,EAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;QACrE,YAAY,GAAG,YAAY,GAAG,WAAW,CAAC;IAC5C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,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*--------------------------------------------------------------------------------------------*/\nimport { InvertedUnit, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatTraits, parseFormatTrait, parseScientificType, parseShowSignOption } from \"@itwin/core-quantity\";\nimport { FormatDifference, FormatUnitDifference, FormatUnitLabelDifference } from \"../Differencing/SchemaDifference\";\nimport { MutableFormat } from \"../Editing/Mutable/MutableFormat\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Format into the target schema.\n * @internal\n */\nexport async function addFormat(context: SchemaMergeContext, change: FormatDifference) {\n if (change.difference.type === undefined) {\n throw new Error(\"Format must define type\");\n }\n\n if (change.difference.composite && change.difference.composite.units) {\n for (let index = 0; index < change.difference.composite.units.length; index++) {\n const compositeUnitName = await updateSchemaItemFullName(context, change.difference.composite.units[index].name);\n change.difference.composite.units[index] = {\n name: compositeUnitName,\n label: change.difference.composite.units[index].label,\n }\n }\n }\n\n await context.editor.formats.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n type: change.difference.type,\n composite: change.difference.composite,\n });\n}\n\n/**\n * Merges differences to an existing Format in the target schema.\n * @internal\n */\nexport async function modifyFormat(context: SchemaMergeContext, change: FormatDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n if (change.difference.type !== undefined) {\n throw new Error(`Changing the format '${change.itemName}' type is not supported.`);\n }\n\n if (change.difference.label !== undefined) {\n await context.editor.formats.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.formats.setDescription(itemKey, change.difference.description);\n }\n if (change.difference.precision !== undefined) {\n format.setPrecision(change.difference.precision);\n }\n if (change.difference.roundFactor !== undefined) {\n format.setRoundFactor(change.difference.roundFactor);\n }\n if (change.difference.minWidth !== undefined) {\n format.setMinWidth(change.difference.minWidth);\n }\n if (change.difference.showSignOption !== undefined) {\n const showSignOption = parseShowSignOption(change.difference.showSignOption, change.itemName);\n format.setShowSignOption(showSignOption);\n }\n if (change.difference.formatTraits !== undefined) {\n const formatTraits = parseFormatTraits(change.difference.formatTraits, change.itemName);\n format.setFormatTraits(formatTraits);\n }\n if (change.difference.decimalSeparator !== undefined) {\n format.setDecimalSeparator(change.difference.decimalSeparator);\n }\n if (change.difference.thousandSeparator !== undefined) {\n format.setThousandSeparator(change.difference.thousandSeparator);\n }\n if (change.difference.uomSeparator !== undefined) {\n format.setUomSeparator(change.difference.uomSeparator);\n }\n if (change.difference.scientificType !== undefined) {\n const scientificType = parseScientificType(change.difference.scientificType, change.itemName);\n format.setScientificType(scientificType);\n }\n if (change.difference.stationOffsetSize !== undefined) {\n format.setStationOffsetSize(change.difference.stationOffsetSize);\n }\n if (change.difference.stationSeparator !== undefined) {\n format.setStationSeparator(change.difference.stationSeparator);\n }\n if (change.difference.composite !== undefined) {\n if (change.difference.composite.includeZero !== undefined) {\n format.setIncludeZero(change.difference.composite.includeZero);\n }\n if (change.difference.composite.spacer !== undefined) {\n format.setSpacer(change.difference.composite.spacer);\n }\n }\n}\n\n/**\n * Merges source format units into the target format\n * @internal\n*/\nexport async function modifyFormatUnit(context: SchemaMergeContext, change: FormatUnitDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n const units: [Unit | InvertedUnit, string | undefined][] = [];\n for (const { name, label } of change.difference) {\n const lookupKey = await updateSchemaItemKey(context, name);\n const formatUnit = await context.editor.schemaContext.getSchemaItem(lookupKey);\n if (formatUnit === undefined || (!Unit.isUnit(formatUnit) && !InvertedUnit.isInvertedUnit(formatUnit))) {\n throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);\n }\n units.push([formatUnit, label]);\n }\n format.setUnits(units);\n}\n\n/**\n * Overrides format unit label\n * @internal\n*/\nexport async function modifyFormatUnitLabel(context: SchemaMergeContext, change: FormatUnitLabelDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n if (format.units !== undefined) {\n const unitKey = await updateSchemaItemKey(context, change.path);\n /* eslint-disable @typescript-eslint/prefer-for-of */\n for (let index = 0; index < format.units.length; index++) {\n if (format.units[index][0].key.matches(unitKey)) {\n format.units[index][1] = change.difference.label;\n }\n }\n }\n}\n\nfunction parseFormatTraits(formatTraitsFromJson: string | string[], formatName: string): FormatTraits {\n let formatTraits: FormatTraits = FormatTraits.Uninitialized;\n const formatTraitIterable = Array.isArray(formatTraitsFromJson)\n ? formatTraitsFromJson\n : formatTraitsFromJson.split(/,|;|\\|/);\n for (const formatTraitsString of formatTraitIterable) {\n const formatTrait = parseFormatTrait(formatTraitsString, formatName);\n formatTraits = formatTraits | formatTrait;\n }\n return formatTraits;\n}\n"]}
@@ -125,7 +125,7 @@ const enumerationProperty = {
125
125
  },
126
126
  async add(context, itemKey, property) {
127
127
  const enumerationKey = await (0, Utils_1.updateSchemaItemKey)(context, property.typeName);
128
- const enumerationType = await context.editor.schemaContext.getSchemaItem(enumerationKey);
128
+ const enumerationType = await context.editor.schemaContext.getSchemaItem(enumerationKey, ecschema_metadata_1.Enumeration);
129
129
  if (enumerationType === undefined) {
130
130
  throw new Error(`Unable to locate the enumeration class ${enumerationKey.name} in the context schema.`);
131
131
  }
@@ -148,7 +148,7 @@ const navigationProperty = {
148
148
  },
149
149
  async add(context, itemKey, property) {
150
150
  const relationshipKey = await (0, Utils_1.updateSchemaItemKey)(context, property.relationshipName);
151
- const relationshipType = await context.editor.schemaContext.getSchemaItem(relationshipKey);
151
+ const relationshipType = await context.editor.schemaContext.getSchemaItem(relationshipKey, ecschema_metadata_1.RelationshipClass);
152
152
  if (relationshipType === undefined) {
153
153
  throw new Error(`Unable to locate the relationship class ${relationshipKey.name} in the context schema.`);
154
154
  }
@@ -213,7 +213,7 @@ const structProperty = {
213
213
  },
214
214
  async add(context, itemKey, property) {
215
215
  const structKey = await (0, Utils_1.updateSchemaItemKey)(context, property.typeName);
216
- const structType = await context.editor.schemaContext.getSchemaItem(structKey);
216
+ const structType = await context.editor.schemaContext.getSchemaItem(structKey, ecschema_metadata_1.StructClass);
217
217
  if (structType === undefined) {
218
218
  throw new Error(`Unable to locate the struct ${structKey.name} in the context schema.`);
219
219
  }